diff options
| author | Alex Flint <[email protected]> | 2016-01-05 16:52:13 -0800 |
|---|---|---|
| committer | Alex Flint <[email protected]> | 2016-01-05 16:52:13 -0800 |
| commit | f8ea16beeeb29e99546599ca08095378a124262f (patch) | |
| tree | a913cc7e3290a3e03cc2b854b81f06b8246358c0 /README.md | |
| parent | d97f8fd931505639da3aa68847629e937de41ef9 (diff) | |
| parent | 9aad09fe14abea44e32a2dabf4768e1eb31527ea (diff) | |
Merge pull request #25 from alexflint/return_parser_from_mustparse
MustParse returns *Parser
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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 |
