summaryrefslogtreecommitdiff
path: root/README.md
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 /README.md
parent34954f45cec4632059c6aa8ca6f769a748464cf7 (diff)
parentf882700b723834ad1371307b81930cde4b81c0aa (diff)
Merge pull request #38 from alexflint/version_string
Add support for version strings
Diffstat (limited to 'README.md')
-rw-r--r--README.md22
1 files changed, 22 insertions, 0 deletions
diff --git a/README.md b/README.md
index 66a9b46..4aa311e 100644
--- a/README.md
+++ b/README.md
@@ -166,6 +166,28 @@ usage: samples [--foo FOO] [--bar BAR]
error: you must provide one of --foo and --bar
```
+### Version strings
+
+```go
+type args struct {
+ ...
+}
+
+func (args) Version() string {
+ return "someprogram 4.3.0"
+}
+
+func main() {
+ var args args
+ arg.MustParse(&args)
+}
+```
+
+```shell
+$ ./example --version
+someprogram 4.3.0
+```
+
### Custom parsing
You can implement your own argument parser by implementing `encoding.TextUnmarshaler`: