diff options
Diffstat (limited to 'usage.go')
| -rw-r--r-- | usage.go | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -76,7 +76,6 @@ func (p *Parser) WriteHelp(w io.Writer) { } } - // write the list of options fmt.Fprint(w, "\noptions:\n") for _, spec := range options { printOption(w, spec) @@ -101,6 +100,13 @@ func printOption(w io.Writer, spec *spec) { } fmt.Fprint(w, spec.help) } + // Check if spec.dest is zero value or not + // If it isn't a default value have been added + v := spec.dest + z := reflect.Zero(v.Type()) + if v.Interface() != z.Interface() { + fmt.Fprintf(w, " [default: %v]", v) + } fmt.Fprint(w, "\n") } |
