Documentation
¶
Overview ¶
Package options works in concert with flag, adding prettier printing of options.
Package options works in concert with flag, adding prettier printing of options.
Index ¶
- Variables
- func Add(option ...Option)
- func Fail(err error, msg string, args ...interface{})
- func FailIf(err error, msg string, args ...interface{})
- func Show(out io.Writer, category string)
- func ShowAll(out io.Writer)
- func ShowRelevant(out io.Writer, category ...Category)
- func Usage(msg string, args ...interface{})
- func WarnIf(err error, msg string, args ...interface{})
- type Category
- type Option
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Options is like flag.CommandLine, the current set of options. It is not kept // in lexicographical order. Initially, it will contain (at least) all the flags // from golang/glog. Options = []Option{} // String maps from name to value for string options added with Add. String = make(map[string]*string) // Bool maps from name to value for boolean options added with Add. Bool = make(map[string]*bool) // Int maps from name to value for int options added with Add. Int = make(map[string]*int) // Duration maps from name to value for time.Duration options added with // Add. Duration = make(map[string]*time.Duration) )
Functions ¶
func Add ¶
func Add(option ...Option)
Add adds one or more options to Options, to the flag package's list, and to the approprate map (either String, Bool, Int, or Duration).
func Fail ¶
Fail prints an error and accompanying message to os.Stderr, then exits the program with status 2. The err parameter can be nil.
func ShowRelevant ¶
ShowRelevant pretty-prints all options relevant to one or more categories.
Types ¶
type Category ¶
type Category struct { // Name for this group of flags. Name string // Description for this group of flags. Description string }
Category describes a group of related command-line flags.
type Option ¶
type Option struct { // Name for this flag, e.g. "pass" Name string // Default value, e.g. "BogusPassword" Default interface{} // Placeholder description of the argument e.g. "<password>" Prototype string // Help message, e.g. "Password for decryption" Help string // Relevance is a comma-separated list of words, used to group the flags // into categories. Relevance string }
Option is like flag.Flag, but supports prettier printing.
Click to show internal directories.
Click to hide internal directories.