MCPcopy Create free account
hub / github.com/DNAProject/DNA / formatCommand

Function formatCommand

cmd/usage.go:330–351  ·  view source on GitHub ↗
(cmds []cli.Command)

Source from the content-addressed store, hash-verified

328func (this *FmtFlag) Apply(*flag.FlagSet) {}
329
330func formatCommand(cmds []cli.Command) []cli.Command {
331 maxWidth := 0
332 for _, cmd := range cmds {
333 if len(cmd.Name) > maxWidth {
334 maxWidth = len(cmd.Name)
335 }
336 }
337 formatter := "%-" + fmt.Sprintf("%d", maxWidth) + "s"
338 newCmds := make([]cli.Command, 0, len(cmds))
339 for _, cmd := range cmds {
340 name := cmd.Name
341 if len(cmd.Aliases) != 0 {
342 for _, aliase := range cmd.Aliases {
343 name += ", " + aliase
344 }
345 cmd.Aliases = nil
346 }
347 cmd.Name = fmt.Sprintf(formatter, name)
348 newCmds = append(newCmds, cmd)
349 }
350 return newCmds
351}
352
353func formatFlags(flags []cli.Flag) []cli.Flag {
354 maxWidth := 0

Callers 1

cusHelpPrinterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected