diff --git a/mflag/example/example.go b/mflag/example/example.go index b0d25fb..352f652 100644 --- a/mflag/example/example.go +++ b/mflag/example/example.go @@ -12,6 +12,7 @@ var ( ) func init() { + flag.Bool([]string{"#hp", "#-halp"}, false, "display the halp") flag.BoolVar(&b, []string{"b"}, false, "a simple bool") flag.BoolVar(&b2, []string{"-bool"}, false, "a simple bool") flag.IntVar(&i, []string{"#integer", "-integer"}, -1, "a simple integer") diff --git a/mflag/flag.go b/mflag/flag.go index 6fe3e41..ff0de23 100644 --- a/mflag/flag.go +++ b/mflag/flag.go @@ -404,7 +404,9 @@ func (f *FlagSet) PrintDefaults() { names = append(names, name) } } - fmt.Fprintf(f.out(), format, strings.Join(names, ", -"), flag.DefValue, flag.Usage) + if len(names) > 0 { + fmt.Fprintf(f.out(), format, strings.Join(names, ", -"), flag.DefValue, flag.Usage) + } }) }