diff options
| author | Alex Flint <[email protected]> | 2015-11-26 22:10:36 +1030 |
|---|---|---|
| committer | Alex Flint <[email protected]> | 2015-11-26 22:10:36 +1030 |
| commit | ce5525d7767a3016c46f0f07e26a5db4b26372c1 (patch) | |
| tree | c04908e5ffca0afa26f9b3b92c11a74621a55a17 /usage.go | |
| parent | 5db9c77fa32bd444360f8376ddfa7bc209813b20 (diff) | |
| parent | 670c7b787d9a475c663e3868eeb226ff7c5e78ad (diff) | |
Merge pull request #19 from walle/add_default_value_to_usage
Add default values to usage
Diffstat (limited to 'usage.go')
| -rw-r--r-- | usage.go | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -5,6 +5,7 @@ import ( "io" "os" "path/filepath" + "reflect" "strings" ) @@ -101,6 +102,15 @@ 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 + if v.IsValid() { + z := reflect.Zero(v.Type()) + if v.Interface() != z.Interface() { + fmt.Fprintf(w, " [default: %v]", v) + } + } fmt.Fprint(w, "\n") } |
