summaryrefslogtreecommitdiff
path: root/usage.go
diff options
context:
space:
mode:
authorFredrik Wallgren <[email protected]>2015-11-22 00:58:27 +0100
committerFredrik Wallgren <[email protected]>2015-11-22 01:06:44 +0100
commit670c7b787d9a475c663e3868eeb226ff7c5e78ad (patch)
treec04908e5ffca0afa26f9b3b92c11a74621a55a17 /usage.go
parentb0d37d1fb2b491a861f788a41aabbe66cbf83110 (diff)
Fix merge conflicts
Diffstat (limited to 'usage.go')
-rw-r--r--usage.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/usage.go b/usage.go
index 64ed901..fa01229 100644
--- a/usage.go
+++ b/usage.go
@@ -5,6 +5,7 @@ import (
"io"
"os"
"path/filepath"
+ "reflect"
"strings"
)
@@ -76,6 +77,7 @@ func (p *Parser) WriteHelp(w io.Writer) {
}
}
+ // write the list of options
fmt.Fprint(w, "\noptions:\n")
for _, spec := range options {
printOption(w, spec)
@@ -103,9 +105,11 @@ func printOption(w io.Writer, spec *spec) {
// 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)
+ if v.IsValid() {
+ z := reflect.Zero(v.Type())
+ if v.Interface() != z.Interface() {
+ fmt.Fprintf(w, " [default: %v]", v)
+ }
}
fmt.Fprint(w, "\n")
}