summaryrefslogtreecommitdiff
path: root/example_test.go
diff options
context:
space:
mode:
authorAlex Flint <[email protected]>2021-04-19 21:27:53 -0700
committerGitHub <[email protected]>2021-04-19 21:27:53 -0700
commita0937d1b588cbb39c0fb9c250ebf21dce42b7dab (patch)
treebb658d951719fb3d0b4ed90df9aded48d4bbaeb1 /example_test.go
parent6a01a15f75472271568c732c1191e9d33a5fc54c (diff)
parent01a9fab8d768fbcb11e51d4df3c8fda6230462da (diff)
Merge pull request #150 from alexflint/push-coverage-up-more
Push test coverage up to 100%
Diffstat (limited to 'example_test.go')
-rw-r--r--example_test.go17
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)