summaryrefslogtreecommitdiff
path: root/usage.go
diff options
context:
space:
mode:
authorAlex Flint <[email protected]>2016-01-18 10:31:01 -0800
committerAlex Flint <[email protected]>2016-01-18 10:31:01 -0800
commitb1ec8c909335d0a72b6887aea5e7428f3cff60a8 (patch)
tree2e15e749e4af7c6d84caa43439592f4407759262 /usage.go
parentc9155bb0c3e57557bae7d7c54b60ab8fe2e95211 (diff)
make it possible to override the name of the program
Diffstat (limited to 'usage.go')
-rw-r--r--usage.go6
1 files changed, 2 insertions, 4 deletions
diff --git a/usage.go b/usage.go
index 61f0ad6..f9d2eb9 100644
--- a/usage.go
+++ b/usage.go
@@ -4,7 +4,6 @@ import (
"fmt"
"io"
"os"
- "path/filepath"
"reflect"
"strings"
)
@@ -30,7 +29,7 @@ func (p *Parser) WriteUsage(w io.Writer) {
}
}
- fmt.Fprintf(w, "usage: %s", filepath.Base(os.Args[0]))
+ fmt.Fprintf(w, "usage: %s", p.config.Program)
// write the option component of the usage message
for _, spec := range options {
@@ -114,8 +113,7 @@ 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
+ // If spec.dest is not the zero value then a default value has been added.
v := spec.dest
if v.IsValid() {
z := reflect.Zero(v.Type())