Fixing the issue with a command with subcommands not showing help message.

- the command name is "" and HasName was returning true for an empty
  ShortName.
- the Show method wasn't aware that command name was just "" and
  returned the first subcommand.
This commit is contained in:
Nicolas Dufour
2015-02-23 08:01:17 -05:00
parent 50c77ecec0
commit 4be878bffc
2 changed files with 7 additions and 1 deletions

View File

@@ -112,6 +112,12 @@ func DefaultAppComplete(c *Context) {
// Prints help for the given command
func ShowCommandHelp(c *Context, command string) {
// show the subcommand help for a command with subcommands
if command == "" {
HelpPrinter(SubcommandHelpTemplate, c.App)
return
}
for _, c := range c.App.Commands {
if c.HasName(command) {
HelpPrinter(CommandHelpTemplate, c)