MCPcopy
hub / github.com/spf13/cobra / Commands

Method Commands

command.go:1332–1339  ·  view source on GitHub ↗

Commands returns a sorted slice of child commands.

()

Source from the content-addressed store, hash-verified

1330
1331// Commands returns a sorted slice of child commands.
1332func (c *Command) Commands() []*Command {
1333 // do not sort commands if it already sorted or sorting was disabled
1334 if EnableCommandSorting && !c.commandsAreSorted {
1335 sort.Sort(commandSorterByName(c.commands))
1336 c.commandsAreSorted = true
1337 }
1338 return c.commands
1339}
1340
1341// AddCommand adds one or more commands to this parent command.
1342func (c *Command) AddCommand(cmds ...*Command) {

Callers 15

TestValidateFlagGroupsFunction · 0.95
getCompletionsMethod · 0.95
TestCompleteCompletionFunction · 0.95
writeCommandsFunction · 0.80
genFunction · 0.80
TestCommandsAreSortedFunction · 0.80
InitDefaultHelpCmdMethod · 0.80
defaultUsageFuncFunction · 0.80
GenManTreeFromOptsFunction · 0.80
genManFunction · 0.80

Calls 1

commandSorterByNameTypeAlias · 0.85

Tested by 5

TestValidateFlagGroupsFunction · 0.76
TestCompleteCompletionFunction · 0.76
TestCommandsAreSortedFunction · 0.64