diff options
| author | Alex Flint <[email protected]> | 2016-09-08 21:18:19 -0700 |
|---|---|---|
| committer | Alex Flint <[email protected]> | 2016-09-08 21:18:19 -0700 |
| commit | c453aa1a28b0cc9baac51cf5cc04df2688d3cd25 (patch) | |
| tree | 7503a5a4f6fad156748c240cb7bec498e8715204 /usage.go | |
| parent | 34954f45cec4632059c6aa8ca6f769a748464cf7 (diff) | |
add support for version string
Diffstat (limited to 'usage.go')
| -rw-r--r-- | usage.go | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -29,6 +29,10 @@ func (p *Parser) WriteUsage(w io.Writer) { } } + if p.version != "" { + fmt.Fprintln(w, p.version) + } + fmt.Fprintf(w, "usage: %s", p.config.Program) // write the option component of the usage message @@ -97,6 +101,9 @@ func (p *Parser) WriteHelp(w io.Writer) { // write the list of built in options printOption(w, &spec{boolean: true, long: "help", short: "h", help: "display this help and exit"}) + if p.version != "" { + printOption(w, &spec{boolean: true, long: "version", help: "display version and exit"}) + } } func printOption(w io.Writer, spec *spec) { |
