Skip to content

Commit

Permalink
Merge pull request #267 from timabell/choice-help
Browse files Browse the repository at this point in the history
Explain how to use choices
  • Loading branch information
jessevdk authored Sep 23, 2018
2 parents 3beeeb6 + cb19eb6 commit b820973
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ var opts struct {
// Example of a required flag
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"`

// Example of a value name
File string `short:"f" long:"file" description:"A file" value-name:"FILE"`

Expand Down
3 changes: 2 additions & 1 deletion flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ The following is a list of tags for struct fields supported by go-flags:
value-name: the name of the argument value (to be shown in the help)
(optional)
choice: limits the values for an option to a set of values.
This tag can be specified multiple times (optional)
Repeat this tag once for each allowable value.
e.g. `long:"animal" choice:"cat" choice:"dog"`
hidden: if non-empty, the option is not visible in the help or man page.
base: a base (radix) used to convert strings to integer values, the
Expand Down

0 comments on commit b820973

Please sign in to comment.