IsAdditionalHelpTopicCommand determines if a command is an additional help topic command; additional help topic command is determined by the fact that it is NOT runnable/hidden/deprecated, and has no sub commands that are runnable/hidden/deprecated. Concrete example: https://github.com/spf13/cobra/i
()
| 1626 | // are runnable/hidden/deprecated. |
| 1627 | // Concrete example: https://github.com/spf13/cobra/issues/393#issuecomment-282741924. |
| 1628 | func (c *Command) IsAdditionalHelpTopicCommand() bool { |
| 1629 | // if a command is runnable, deprecated, or hidden it is not a 'help' command |
| 1630 | if c.Runnable() || len(c.Deprecated) != 0 || c.Hidden { |
| 1631 | return false |
| 1632 | } |
| 1633 | |
| 1634 | // if any non-help sub commands are found, the command is not a 'help' command |
| 1635 | for _, sub := range c.commands { |
| 1636 | if !sub.IsAdditionalHelpTopicCommand() { |
| 1637 | return false |
| 1638 | } |
| 1639 | } |
| 1640 | |
| 1641 | // the command either has no sub commands, or no non-help sub commands |
| 1642 | return true |
| 1643 | } |
| 1644 | |
| 1645 | // HasHelpSubCommands determines if a command has any available 'help' sub commands |
| 1646 | // that need to be shown in the usage/help default template under 'additional help |
no test coverage detected