summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md18
1 files changed, 18 insertions, 0 deletions
diff --git a/README.md b/README.md
index 93f2574..f4c8d11 100644
--- a/README.md
+++ b/README.md
@@ -108,6 +108,24 @@ fmt.Printf("Fetching the following IDs from %s: %q", args.Database, args.IDs)
Fetching the following IDs from foo: [1 2 3]
```
+### Custom validation
+```go
+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")
+}
+```
+
+```shell
+./example
+usage: samples [--foo FOO] [--bar BAR]
+error: you must provide one of --foo and --bar
+```
+
### Installation
```shell