summaryrefslogtreecommitdiff
path: root/usage.go
diff options
context:
space:
mode:
authorAlex Flint <[email protected]>2016-09-13 18:47:19 -0700
committerGitHub <[email protected]>2016-09-13 18:47:19 -0700
commite6fdb157e91f007265d9db6bbc7029d18bab4f6b (patch)
treef3fd21042b15291d79e259bdfaffe458437d1c56 /usage.go
parent34954f45cec4632059c6aa8ca6f769a748464cf7 (diff)
parentf882700b723834ad1371307b81930cde4b81c0aa (diff)
Merge pull request #38 from alexflint/version_string
Add support for version strings
Diffstat (limited to 'usage.go')
-rw-r--r--usage.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/usage.go b/usage.go
index 2ee3953..f096f58 100644
--- a/usage.go
+++ b/usage.go
@@ -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) {