summaryrefslogtreecommitdiff
path: root/example_test.go
diff options
context:
space:
mode:
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)