Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
farbodsalimi committed Dec 18, 2018
1 parent 5de817a commit 594cb3b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var opts struct {
Name string `short:"n" long:"name" description:"A name" required:"true"`

// Example of a flag restricted to a pre-defined set of strings
Name string `long:"animal" choice:"cat" choice:"dog"`
Animal string `long:"animal" choice:"cat" choice:"dog"`

// Example of a value name
File string `short:"f" long:"file" description:"A file" value-name:"FILE"`
Expand Down Expand Up @@ -94,6 +94,7 @@ args := []string{
"-vv",
"--offset=5",
"-n", "Me",
"--animal", "dog", // anything other than "cat" or "dog" will raise an error
"-p", "3",
"-s", "hello",
"-s", "world",
Expand All @@ -118,6 +119,7 @@ if err != nil {
fmt.Printf("Verbosity: %v\n", opts.Verbose)
fmt.Printf("Offset: %d\n", opts.Offset)
fmt.Printf("Name: %s\n", opts.Name)
fmt.Printf("Animal: %s\n", opts.Animal)
fmt.Printf("Ptr: %d\n", *opts.Ptr)
fmt.Printf("StringSlice: %v\n", opts.StringSlice)
fmt.Printf("PtrSlice: [%v %v]\n", *opts.PtrSlice[0], *opts.PtrSlice[1])
Expand Down

0 comments on commit 594cb3b

Please sign in to comment.