diff --git a/flag.go b/flag.go index 24a5036e..3a6990cd 100644 --- a/flag.go +++ b/flag.go @@ -178,6 +178,7 @@ type Flag struct { NoOptDefVal string // default value (as text); if the flag is on the command line without any options Deprecated string // If this flag is deprecated, this string is the new or now thing to use Hidden bool // used by cobra.Command to allow flags to be hidden from help/usage text + HideDefaultUsage bool // used to hide [=""] addition in help/usage text if a default is set ShorthandDeprecated string // If the shorthand of this flag is deprecated, this string is the new or now thing to use Annotations map[string][]string // used by cobra.Command bash autocomple code } @@ -696,7 +697,7 @@ func (f *FlagSet) FlagUsagesWrapped(cols int) string { if varname != "" { line += " " + varname } - if flag.NoOptDefVal != "" { + if flag.NoOptDefVal != "" && !flag.HideDefaultUsage { switch flag.Value.Type() { case "string": line += fmt.Sprintf("[=\"%s\"]", flag.NoOptDefVal) @@ -721,7 +722,7 @@ func (f *FlagSet) FlagUsagesWrapped(cols int) string { } line += usage - if !flag.defaultIsZeroValue() { + if !flag.defaultIsZeroValue() && !flag.HideDefaultUsage { if flag.Value.Type() == "string" { line += fmt.Sprintf(" (default %q)", flag.DefValue) } else {