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

Function UsageCommands

codegen/cli/cli.go:250–266  ·  view source on GitHub ↗

UsageCommands builds a section template that generates a help text showing the list of allowed commands and sub-commands.

(data []*CommandData)

Source from the content-addressed store, hash-verified

248// UsageCommands builds a section template that generates a help text showing
249// the list of allowed commands and sub-commands.
250func UsageCommands(data []*CommandData) *codegen.SectionTemplate {
251 usages := make([]string, len(data))
252 for i, cmd := range data {
253 subs := make([]string, len(cmd.Subcommands))
254 for i, s := range cmd.Subcommands {
255 subs[i] = s.Name
256 }
257 var lp, rp string
258 if len(subs) > 1 {
259 lp = "("
260 rp = ")"
261 }
262 usages[i] = fmt.Sprintf("%s %s%s%s", cmd.Name, lp, strings.Join(subs, "|"), rp)
263 }
264
265 return &codegen.SectionTemplate{Source: cliTemplates.Read(usageCommandsT), Data: usages}
266}
267
268// UsageExamples builds a section template that generates a help text showing
269// a valid invocation of the CLI tool.

Callers 2

endpointParserFunction · 0.92
endpointParserFunction · 0.92

Calls 1

ReadMethod · 0.45

Tested by

no test coverage detected