Merge pull request #481 from urfave/fix-subcommand-help-flag
Correctly show help message if `-h` is provided to subcommand
This commit is contained in:
commit
f4ee034378
@ -908,6 +908,7 @@ func TestApp_Run_CommandWithSubcommandHasHelpTopic(t *testing.T) {
|
|||||||
Name: "foo",
|
Name: "foo",
|
||||||
Description: "descriptive wall of text about how it does foo things",
|
Description: "descriptive wall of text about how it does foo things",
|
||||||
Subcommands: []Command{subCmdBar, subCmdBaz},
|
Subcommands: []Command{subCmdBar, subCmdBaz},
|
||||||
|
Action: func(c *Context) error { return nil },
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Commands = []Command{cmd}
|
app.Commands = []Command{cmd}
|
||||||
|
2
help.go
2
help.go
@ -240,7 +240,7 @@ func checkCommandHelp(c *Context, name string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkSubcommandHelp(c *Context) bool {
|
func checkSubcommandHelp(c *Context) bool {
|
||||||
if c.GlobalBool("h") || c.GlobalBool("help") {
|
if c.Bool("h") || c.Bool("help") {
|
||||||
ShowSubcommandHelp(c)
|
ShowSubcommandHelp(c)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user