Merge pull request #46 from eparis/goreportcard
Fix up minor things found by goreportcard.com
diff --git a/flag.go b/flag.go
index 12d718b..81b3c1f 100644
--- a/flag.go
+++ b/flag.go
@@ -365,31 +365,8 @@
// PrintDefaults prints, to standard error unless configured
// otherwise, the default values of all defined flags in the set.
func (f *FlagSet) PrintDefaults() {
- f.VisitAll(func(flag *Flag) {
- if len(flag.Deprecated) > 0 {
- return
- }
- format := ""
- // ex: w/ option string argument '-%s, --%s[=%q]: %s\n'
- if len(flag.Shorthand) > 0 {
- format = " -%s, --%s"
- } else {
- format = " %s --%s"
- }
- if len(flag.NoOptDefVal) > 0 {
- format = format + "["
- }
- if _, ok := flag.Value.(*stringValue); ok {
- format = format + "=%q"
- } else {
- format = format + "=%s"
- }
- if len(flag.NoOptDefVal) > 0 {
- format = format + "]"
- }
- format = format + ": %s\n"
- fmt.Fprintf(f.out(), format, flag.Shorthand, flag.Name, flag.DefValue, flag.Usage)
- })
+ usages := f.FlagUsages()
+ fmt.Fprintf(f.out(), "%s", usages)
}
// FlagUsages Returns a string containing the usage information for all flags in