Documentation ¶
Overview ¶
Package flag provides extended support for flag parsing. It uses the standard flag package underneath but adds automatic flag registration from structures, more types of flags, and some support funcitons for adding more flag types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Choice ¶
type Choice interface {
String() string
}
Choice is the interface to something that represents a value for an enumerated type.
type Choices ¶
type Choices []Choice
Choices is a slice of Enum values for a given type.
type Choosable ¶
type Choosable interface { // Chooser returns a Chooser object that can be used to select values for the implementing type. Chooser() Chooser }
Choosable is the interface to type that can return a chooser for itself. Anything that implements Choosable is direclty usesable as a flag value.
type Chooser ¶
type Chooser struct { // Value is the value we are choosing for. Value Enum // Choices is the full set of choices available. Choices Choices }
Chooser is is used to select from amongst a set of choices. It conforms to the flag.Value interface.
func ForEnum ¶
ForEnum automatically builds a Chooser for a 0 based sequential enumerated integer type up to 1000. It expects that the values will all have names from the first to the last, starting at 0, and that after the end of the valid range the string method for the type will either return the empty string or strconv.Itoa of the base value.
type Enum ¶
type Enum interface { // String represents the current value in a string form, used for choice matching. String() string // Choose is handed a value to set from the Choices list for the enum. Choose(interface{}) }
Enum is the interface to a enumerated value. Anything that implements Enum is direclty usesable as a flag value.
type Set ¶
type Set struct { // Raw is the underlying flag set // TODO: hide this once we stop things relying on it Raw flag.FlagSet }
func (*Set) Bind ¶
Bind uses reflection to bind flag values to the verb. It will recurse into nested structures adding all leaf fields.
func (*Set) ForceCommandLine ¶
func (s *Set) ForceCommandLine()
ForceCommandLine is an ugly hack for things that try to directly use the flag package TODO: remove this
func (*Set) HasVisibleFlags ¶
HasVisibleFlags returns true if the set has bound flags for the specified verbosity.