diff options
| author | Alex Flint <[email protected]> | 2021-04-19 21:03:43 -0700 |
|---|---|---|
| committer | Alex Flint <[email protected]> | 2021-04-19 21:03:43 -0700 |
| commit | fe4a138ac8c39cb00bbee7279a0957897ab88fae (patch) | |
| tree | 02b48894c636a05751125c495d8325dd2f92fe4f /example_test.go | |
| parent | 6a01a15f75472271568c732c1191e9d33a5fc54c (diff) | |
test coverage 100% !!
Diffstat (limited to 'example_test.go')
| -rw-r--r-- | example_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/example_test.go b/example_test.go index 5645156..26f24e7 100644 --- a/example_test.go +++ b/example_test.go @@ -95,6 +95,19 @@ func Example_mappings() { // output: map[john:123 mary:456] } +// This example demonstrates arguments with keys and values separated by commas +func Example_mappingsWithCommas() { + // The args you would pass in on the command line + os.Args = split("./example --userids john=123 mary=456") + + var args struct { + UserIDs map[string]int + } + MustParse(&args) + fmt.Println(args.UserIDs) + // output: map[john:123 mary:456] +} + // This eample demonstrates multiple value arguments that can be mixed with // other arguments. func Example_multipleMixed() { @@ -130,6 +143,7 @@ func Example_helpText() { // This is only necessary when running inside golang's runnable example harness osExit = func(int) {} + stdout = os.Stdout MustParse(&args) @@ -162,6 +176,7 @@ func Example_helpPlaceholder() { // This is only necessary when running inside golang's runnable example harness osExit = func(int) {} + stdout = os.Stdout MustParse(&args) @@ -202,6 +217,7 @@ func Example_helpTextWithSubcommand() { // This is only necessary when running inside golang's runnable example harness osExit = func(int) {} + stdout = os.Stdout MustParse(&args) @@ -239,6 +255,7 @@ func Example_helpTextForSubcommand() { // This is only necessary when running inside golang's runnable example harness osExit = func(int) {} + stdout = os.Stdout MustParse(&args) |
