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)
| 283 | // arguments (method payload) invoked by the tool. It panics if any error |
| 284 | // occurs during the generation of flag parsing code. |
| 285 | func 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. |
no test coverage detected