"reflect"
"sort"
"strconv"
+ "strings"
"time"
)
return
}
-// PrintDefaults prints to standard error the default values of all
-// defined command-line flags in the set. See the documentation for
-// the global function PrintDefaults for more information.
+// PrintDefaults prints, to standard error unless configured otherwise, the
+// default values of all defined command-line flags in the set. See the
+// documentation for the global function PrintDefaults for more information.
func (f *FlagSet) PrintDefaults() {
f.VisitAll(func(flag *Flag) {
s := fmt.Sprintf(" -%s", flag.Name) // Two spaces before -; see next two comments.
// for both 4- and 8-space tab stops.
s += "\n \t"
}
- s += usage
+ s += strings.Replace(usage, "\n", "\n \t", -1)
+
if !isZeroValue(flag, flag.DefValue) {
if _, ok := flag.Value.(*stringValue); ok {
// put quotes on the value
a non-zero number (default 2.7)
-G float
a float that defaults to zero
+ -M string
+ a multiline
+ help
+ string
-N int
a non-zero int (default 27)
+ -O a flag
+ multiline help string (default true)
-Z int
an int that defaults to zero
-maxT timeout
fs.String("D", "", "set relative `path` for local imports")
fs.Float64("F", 2.7, "a non-zero `number`")
fs.Float64("G", 0, "a float that defaults to zero")
+ fs.String("M", "", "a multiline\nhelp\nstring")
fs.Int("N", 27, "a non-zero int")
+ fs.Bool("O", true, "a flag\nmultiline help string")
fs.Int("Z", 0, "an int that defaults to zero")
fs.Duration("maxT", 0, "set `timeout` for dial")
fs.PrintDefaults()