summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Flint <[email protected]>2016-01-05 13:57:01 -0800
committerAlex Flint <[email protected]>2016-01-05 13:57:01 -0800
commitf89698667c0b2138445c719101fe7a4d55764738 (patch)
tree24584dea02e0bce4ac434ed8ecea8e27d75eb4e8
parent0c0f9a53aceb964ef68ea55c57a36a9e374f00e8 (diff)
add custom validation example to README
-rw-r--r--README.md12
1 files changed, 12 insertions, 0 deletions
diff --git a/README.md b/README.md
index 93f2574..4a11914 100644
--- a/README.md
+++ b/README.md
@@ -108,6 +108,18 @@ fmt.Printf("Fetching the following IDs from %s: %q", args.Database, args.IDs)
Fetching the following IDs from foo: [1 2 3]
```
+### Custom validation
+```
+var args struct {
+ Foo string
+ Bar string
+}
+p := arg.MustParse(&args)
+if args.Foo == "" && args.Bar == "" {
+ p.Fail("you must provide one of --foo and --bar)
+}
+```
+
### Installation
```shell