From b1ec8c909335d0a72b6887aea5e7428f3cff60a8 Mon Sep 17 00:00:00 2001 From: Alex Flint Date: Mon, 18 Jan 2016 10:31:01 -0800 Subject: make it possible to override the name of the program --- usage.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'usage.go') 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()) -- cgit v1.2.3