aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Ogier <[email protected]>2012-05-04 14:22:37 -0400
committerAlex Ogier <[email protected]>2012-05-04 14:22:37 -0400
commit8999eae83e7efe65a6ad1860c7f9ce5cf3c9b679 (patch)
tree72b1f29a3de0e7bbd144e09f0b29f49047ece47b
parentde8374ac74443f8b8c776f30da7e11be627b1496 (diff)
Print defaults with nice spacing regardless of shortcuts
-rw-r--r--flag.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/flag.go b/flag.go
index 3a39733..74685b8 100644
--- a/flag.go
+++ b/flag.go
@@ -368,15 +368,15 @@ func Set(name, value string) error {
// otherwise, the default values of all defined flags in the set.
func (f *FlagSet) PrintDefaults() {
f.VisitAll(func(flag *Flag) {
- format := " --%s=%s: %s\n"
+ format := "--%s=%s: %s\n"
if _, ok := flag.Value.(*stringValue); ok {
// put quotes on the value
- format = " --%s=%q: %s\n"
+ format = "--%s=%q: %s\n"
}
if len(flag.Shortcut) > 0 {
- format = " -%s," + format[1:]
+ format = " -%s, " + format
} else {
- format = "%s" + format
+ format = " %s " + format
}
fmt.Fprintf(f.out(), format, flag.Shortcut, flag.Name, flag.DefValue, flag.Usage)
})