mirror of
https://github.com/spf13/cobra.git
synced 2024-11-15 09:48:19 -07:00
parent
6ed17b5128
commit
867d414548
@ -721,7 +721,13 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
|
||||
func (c *Command) initHelpFlag() {
|
||||
c.mergePersistentFlags()
|
||||
if c.Flags().Lookup("help") == nil {
|
||||
c.Flags().BoolP("help", "h", false, "help for "+c.Name())
|
||||
usage := "help for "
|
||||
if c.Name() == "" {
|
||||
usage += "this command"
|
||||
} else {
|
||||
usage += c.Name()
|
||||
}
|
||||
c.Flags().BoolP("help", "h", false, usage)
|
||||
}
|
||||
}
|
||||
|
||||
@ -745,6 +751,7 @@ func (c *Command) initHelpCmd() {
|
||||
c.Printf("Unknown help topic %#q\n", args)
|
||||
c.Root().Usage()
|
||||
} else {
|
||||
cmd.initHelpFlag() // make possible 'help' flag to be shown
|
||||
cmd.Help()
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user