Commands returns a sorted slice of child commands.
()
| 1330 | |
| 1331 | // Commands returns a sorted slice of child commands. |
| 1332 | func (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. |
| 1342 | func (c *Command) AddCommand(cmds ...*Command) { |