This commit is contained in:
Schley Andrew Kutz 2015-08-28 21:11:23 +00:00
commit 7c00b28170
2 changed files with 12 additions and 1 deletions

View file

@ -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.

View file

@ -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
}