mirror of
https://github.com/spf13/cobra
synced 2025-05-05 12:57:22 +00:00
Merge 1169e1f351
into 7cd6c9c000
This commit is contained in:
commit
7c00b28170
2 changed files with 12 additions and 1 deletions
9
cobra.go
9
cobra.go
|
@ -34,6 +34,15 @@ var EnablePrefixMatching bool = false
|
|||
// enables an information splash screen on Windows if the CLI is started from explorer.exe.
|
||||
var EnableWindowsMouseTrap bool = true
|
||||
|
||||
// HelpFlagShorthand is the character used to for the help flag's shorthand notation. The
|
||||
// default value is "h".
|
||||
var HelpFlagShorthand string = "h"
|
||||
|
||||
// HelpFlagUsageFormatString is the format string used with fmt.Sprintf to produce the
|
||||
// usage value for the help flag. The name of a given command is substituted in the
|
||||
// formatted result.
|
||||
var HelpFlagUsageFormatString string = "help for %s"
|
||||
|
||||
var MousetrapHelpText string = `This is a command line tool
|
||||
|
||||
You need to open cmd.exe and run it from there.
|
||||
|
|
|
@ -859,7 +859,9 @@ func (c *Command) Flags() *flag.FlagSet {
|
|||
c.flagErrorBuf = new(bytes.Buffer)
|
||||
}
|
||||
c.flags.SetOutput(c.flagErrorBuf)
|
||||
c.PersistentFlags().BoolVarP(&c.helpFlagVal, "help", "h", false, "help for "+c.Name())
|
||||
c.PersistentFlags().BoolVarP(&c.helpFlagVal, "help",
|
||||
HelpFlagShorthand, false,
|
||||
fmt.Sprintf(HelpFlagUsageFormatString, c.Name()))
|
||||
}
|
||||
return c.flags
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue