Documentation ¶
Overview ¶
Package flags parses boolean options from command arguments.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Flags ¶
type Flags struct { ByName ByName // contains filtered or unexported fields }
func New ¶
Define and parse boolean flags from command arguments.
If an argument has a leading hyphen ('-') followed by runes that all match '-?' flags, the respective flags are set and the argument is removed from the returned list, e.g.
flag, args := flags.New([]string{"-abc"}, "-a", "-b", "-c")
results in
flag.ByName("-a") == true flag.ByName("-b") == true flag.ByName("-c") == true args == []string{}
whereas
flag, args := flags.New([]string{"-abcd"}, "-a", "-b", "-c")
results in
flag.ByName["-a"] == false flag.ByName["-b"] == false flag.ByName["-c"] == false args == []string{"-abcd"}
Flags may be defined with strings or string slices that include aliases of the first entry, e.g.
flag, args := flags.New([]string{"-color"}, "-a", "-b", []string{"-c", "-color", "-colour"})
results in
flag.ByName("-a") == false flag.ByName("-b") == false flag.ByName("-c") == true args == []string{}
Click to show internal directories.
Click to hide internal directories.