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

Method HasAvailableSubCommands

command.go:1662–1674  ·  view source on GitHub ↗

HasAvailableSubCommands determines if a command has available sub commands that need to be shown in the usage/help default template under 'available commands'.

()

Source from the content-addressed store, hash-verified

1660// HasAvailableSubCommands determines if a command has available sub commands that
1661// need to be shown in the usage/help default template under 'available commands'.
1662func (c *Command) HasAvailableSubCommands() bool {
1663 // return true on the first found available (non deprecated/help/hidden)
1664 // sub command
1665 for _, sub := range c.commands {
1666 if sub.IsAvailableCommand() {
1667 return true
1668 }
1669 }
1670
1671 // the command either has no sub commands, or no available (non deprecated/help/hidden)
1672 // sub commands
1673 return false
1674}
1675
1676// HasParent determines if the command is a child command.
1677func (c *Command) HasParent() bool {

Callers 2

IsAvailableCommandMethod · 0.95
defaultUsageFuncFunction · 0.80

Calls 1

IsAvailableCommandMethod · 0.80

Tested by

no test coverage detected