diff options
| author | K3A <[email protected]> | 2017-03-09 18:25:56 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-03-09 18:25:56 +0100 |
| commit | b413f8dfb0b6a402b0c048d3a0c582a9f677f98b (patch) | |
| tree | 730568a77df398d2e301759125f7287c44935918 /example_test.go | |
| parent | 9e6f80aa9097a84b3a55750bb83a2afebedc30f0 (diff) | |
| parent | e6e0f59a1777b399abbd2ad840811ad5d6bab04e (diff) | |
Merge branch 'master' into master
Diffstat (limited to 'example_test.go')
| -rw-r--r-- | example_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/example_test.go b/example_test.go index 6fb5197..c34effa 100644 --- a/example_test.go +++ b/example_test.go @@ -71,6 +71,21 @@ func Example_multipleValues() { fmt.Printf("Fetching the following IDs from %s: %q", args.Database, args.IDs) } +// This eample demonstrates multiple value arguments that can be mixed with +// other arguments. +func Example_multipleMixed() { + os.Args = []string{"./example", "-c", "cmd1", "db1", "-f", "file1", "db2", "-c", "cmd2", "-f", "file2", "-f", "file3", "db3", "-c", "cmd3"} + var args struct { + Commands []string `arg:"-c,separate"` + Files []string `arg:"-f,separate"` + Databases []string `arg:"positional"` + } + MustParse(&args) + fmt.Println("Commands:", args.Commands) + fmt.Println("Files", args.Files) + fmt.Println("Databases", args.Databases) +} + // This example shows the usage string generated by go-arg func Example_usageString() { // These are the args you would pass in on the command line |
