MCPcopy Create free account
hub / github.com/goadesign/goa / FlagsCode

Function FlagsCode

codegen/cli/cli.go:285–299  ·  view source on GitHub ↗

FlagsCode returns a string containing the code that parses the command-line flags to infer the command (service), sub-command (method), and the arguments (method payload) invoked by the tool. It panics if any error occurs during the generation of flag parsing code.

(data []*CommandData)

Source from the content-addressed store, hash-verified

283// arguments (method payload) invoked by the tool. It panics if any error
284// occurs during the generation of flag parsing code.
285func FlagsCode(data []*CommandData) string {
286 section := codegen.SectionTemplate{
287 Name: "parse-endpoint-flags",
288 Source: cliTemplates.Read(parseFlagsT),
289 Data: data,
290 FuncMap: map[string]any{"printDescription": printDescription},
291 }
292 var flagsCode bytes.Buffer
293 err := section.Write(&flagsCode)
294 if err != nil {
295 panic(err)
296 }
297
298 return flagsCode.String()
299}
300
301// CommandUsage builds the section templates that can be used to generate the
302// endpoint command usage code.

Callers 2

endpointParserFunction · 0.92
endpointParserFunction · 0.92

Calls 3

WriteMethod · 0.95
StringMethod · 0.65
ReadMethod · 0.45

Tested by

no test coverage detected