Documentation
¶
Index ¶
- Variables
- type DefaultFlagSet
- func (flagSet *DefaultFlagSet) Bool(name string, defaultValue bool, usage string)
- func (flagSet *DefaultFlagSet) DefaultUsage() string
- func (flagSet *DefaultFlagSet) Duration(name string, defaultValue time.Duration, usage string)
- func (flagSet *DefaultFlagSet) Float(name string, defaultValue float64, usage string)
- func (flagSet *DefaultFlagSet) Get(name string) interface{}
- func (flagSet *DefaultFlagSet) GetBool(name string) (bool, bool)
- func (flagSet *DefaultFlagSet) GetDuration(name string) (time.Duration, bool)
- func (flagSet *DefaultFlagSet) GetFloat(name string) (float64, bool)
- func (flagSet *DefaultFlagSet) GetInt(name string) (int64, bool)
- func (flagSet *DefaultFlagSet) GetString(name string) (string, bool)
- func (flagSet *DefaultFlagSet) GetStringArray(name string) ([]string, bool)
- func (flagSet *DefaultFlagSet) GetUint(name string) (uint64, bool)
- func (flagSet *DefaultFlagSet) Int(name string, defaultValue int64, usage string)
- func (flagSet *DefaultFlagSet) Parse(args []string) ([]string, error)
- func (flagSet *DefaultFlagSet) Parsed() bool
- func (flagSet *DefaultFlagSet) Set(name, value string) error
- func (flagSet *DefaultFlagSet) String(name string, defaultValue string, usage string)
- func (flagSet *DefaultFlagSet) StringArray(name string, defaultValue []string, usage string)
- func (flagSet *DefaultFlagSet) SubFlagSet(name string) FlagSet
- func (flagSet *DefaultFlagSet) Uint(name string, defaultValue uint64, usage string)
- func (flagSet *DefaultFlagSet) Var(value Value, name, usage string)
- type FlagDefiner
- type FlagHandler
- type FlagHandlerFunction
- type FlagSet
- type FlagValues
- type StringArrayFlag
- type Value
Constants ¶
This section is empty.
Variables ¶
var ( // ErrHelp is the error returned if the -help or -h flag is invoked but no such flag is defined. ErrHelp error = flag.ErrHelp )
Functions ¶
This section is empty.
Types ¶
type DefaultFlagSet ¶
type DefaultFlagSet struct {
// contains filtered or unexported fields
}
DefaultFlagSet is the basic FlagSet implementation using the standard golang flag library
func NewDefaultFlagSet ¶
func NewDefaultFlagSet() *DefaultFlagSet
NewDefaultFlagSet returns a new DefaultFlagSet.
func NewDefaultFlagSetWithBase ¶
func NewDefaultFlagSetWithBase(flagSet *flag.FlagSet) *DefaultFlagSet
NewDefaultFlagSetWithBase returns a new DefaultFlagSet using the specified flag.FlagSet as a base.
func (*DefaultFlagSet) Bool ¶
func (flagSet *DefaultFlagSet) Bool(name string, defaultValue bool, usage string)
Bool defines a bool flag with specified name, default value, and usage string.
func (*DefaultFlagSet) DefaultUsage ¶ added in v0.7.0
func (flagSet *DefaultFlagSet) DefaultUsage() string
DefaultUsage returns a usage message showing the default settings of all defined command-line flags.
func (*DefaultFlagSet) Duration ¶
func (flagSet *DefaultFlagSet) Duration(name string, defaultValue time.Duration, usage string)
Duration defines a time.Duration flag with specified name, default value, and usage string.
func (*DefaultFlagSet) Float ¶
func (flagSet *DefaultFlagSet) Float(name string, defaultValue float64, usage string)
Float defines a float64 flag with specified name, default value, and usage string.
func (*DefaultFlagSet) Get ¶
func (flagSet *DefaultFlagSet) Get(name string) interface{}
Get returns the value of the named flag.
func (*DefaultFlagSet) GetBool ¶
func (flagSet *DefaultFlagSet) GetBool(name string) (bool, bool)
GetBool returns the value of a named flag as a bool.
func (*DefaultFlagSet) GetDuration ¶
func (flagSet *DefaultFlagSet) GetDuration(name string) (time.Duration, bool)
GetDuration returns the value of a named flag as a time.Duration.
func (*DefaultFlagSet) GetFloat ¶
func (flagSet *DefaultFlagSet) GetFloat(name string) (float64, bool)
GetFloat returns the value of a named flag as a float64.
func (*DefaultFlagSet) GetInt ¶
func (flagSet *DefaultFlagSet) GetInt(name string) (int64, bool)
GetInt returns the value of a named flag as a int64.
func (*DefaultFlagSet) GetString ¶
func (flagSet *DefaultFlagSet) GetString(name string) (string, bool)
GetString returns the value of a named flag as a string.
func (*DefaultFlagSet) GetStringArray ¶
func (flagSet *DefaultFlagSet) GetStringArray(name string) ([]string, bool)
GetStringArray returns the value of a named flag as a string array.
func (*DefaultFlagSet) GetUint ¶
func (flagSet *DefaultFlagSet) GetUint(name string) (uint64, bool)
GetUint returns the value of a named flag as a uint64.
func (*DefaultFlagSet) Int ¶
func (flagSet *DefaultFlagSet) Int(name string, defaultValue int64, usage string)
Int defines a int64 flag with specified name, default value, and usage string.
func (*DefaultFlagSet) Parse ¶
func (flagSet *DefaultFlagSet) Parse(args []string) ([]string, error)
Parse parses flag definitions from the argument list, which should not include the command name, and return remaining, non-flag, arguments. Must be called after all flags in the FlagSet are defined and before flags are accessed by the program. The return value will be ErrHelp if -help was set but not defined.
func (*DefaultFlagSet) Parsed ¶
func (flagSet *DefaultFlagSet) Parsed() bool
Parsed returns true if Parse has been called.
func (*DefaultFlagSet) Set ¶
func (flagSet *DefaultFlagSet) Set(name, value string) error
Set sets the value of the named flag.
func (*DefaultFlagSet) String ¶
func (flagSet *DefaultFlagSet) String(name string, defaultValue string, usage string)
String defines a string flag with specified name, default value, and usage string.
func (*DefaultFlagSet) StringArray ¶
func (flagSet *DefaultFlagSet) StringArray(name string, defaultValue []string, usage string)
StringArray defines a string array flag with specified name, default value, and usage string.
func (*DefaultFlagSet) SubFlagSet ¶
func (flagSet *DefaultFlagSet) SubFlagSet(name string) FlagSet
SubFlagSet creates a new flagset that will be used by sub routers and sub commands.
func (*DefaultFlagSet) Uint ¶
func (flagSet *DefaultFlagSet) Uint(name string, defaultValue uint64, usage string)
Uint defines a unit64 flag with specified name, default value, and usage string.
func (*DefaultFlagSet) Var ¶
func (flagSet *DefaultFlagSet) Var(value Value, name, usage string)
Var defines a flag with the specified name and usage string. The type and value of the flag are represented by the first argument, of type Value, which typically holds a user-defined implementation of Value.
type FlagDefiner ¶
type FlagDefiner interface { // Bool defines a bool flag with specified name, default value, and usage string. Bool(name string, defaultValue bool, usage string) // Int defines a int64 flag with specified name, default value, and usage string. Int(name string, defaultValue int64, usage string) // Uint defines a unit64 flag with specified name, default value, and usage string. Uint(name string, defaultValue uint64, usage string) // String defines a string flag with specified name, default value, and usage string. String(name string, defaultValue string, usage string) // StringArray defines a string array flag with specified name, default value, and usage string. StringArray(name string, defaultValue []string, usage string) // Float defines a float64 flag with specified name, default value, and usage string. Float(name string, defaultValue float64, usage string) // Duration defines a time.Duration flag with specified name, default value, and usage string. Duration(name string, defaultValue time.Duration, usage string) // Var defines a flag with the specified name and usage string. // The type and value of the flag are represented by the first argument, // of type Value, which typically holds a user-defined implementation of Value. Var(value Value, name, usage string) }
FlagDefiner allows you to define the flags managed by the flag set
type FlagHandler ¶
type FlagHandler interface { // Define allows the function to define command-line flags Define(FlagDefiner) }
FlagHandler allows shell handlers to define additional
type FlagHandlerFunction ¶
type FlagHandlerFunction func(FlagDefiner)
The FlagHandlerFunction type is an adapter to allow the use of ordinary functions as shell flag handlers.
func (FlagHandlerFunction) Define ¶
func (handler FlagHandlerFunction) Define(flagDefiner FlagDefiner)
Define allows the function to define command-line flags
type FlagSet ¶
type FlagSet interface { FlagDefiner FlagValues // SubFlagSet creates a new flagset that will be used by sub routers and sub commands. SubFlagSet(name string) FlagSet // Parse parses flag definitions from the argument list, which should not include the command name, and return remaining, non-flag, arguments. // Must be called after all flags in the FlagSet are defined and before flags are accessed by the program. // The return value will be ErrHelp if -help was set but not defined. Parse(args []string) ([]string, error) // Parsed returns true if Parse has been called. Parsed() bool // DefaultUsage returns a usage message showing the default // settings of all defined command-line flags. DefaultUsage() string }
A FlagSet represents a set of defined flags
type FlagValues ¶
type FlagValues interface { // Get returns the value of the named flag. Get(name string) interface{} // GetBool returns the value of a named flag as a bool. GetBool(name string) (bool, bool) // GetInt returns the value of a named flag as a int64. GetInt(name string) (int64, bool) // GetUint returns the value of a named flag as a uint64. GetUint(name string) (uint64, bool) // GetString returns the value of a named flag as a string. GetString(name string) (string, bool) // GetStringArray returns the value of a named flag as a string array. GetStringArray(name string) ([]string, bool) // GetFloat returns the value of a named flag as a float64. GetFloat(name string) (float64, bool) // GetDuration returns the value of a named flag as a time.Duration. GetDuration(name string) (time.Duration, bool) // Set sets the value of the named flag. Set(name, value string) error }
FlagValues allows you to retreive flags
type StringArrayFlag ¶
type StringArrayFlag []string
StringArrayFlag is a Value implementation that adds string array support to the FlagSet StringArrayFlag supports multiple uses of the same flag, as well as comma seperated lists.
func (*StringArrayFlag) Get ¶
func (flag *StringArrayFlag) Get() interface{}
Get returns the string array value.
func (*StringArrayFlag) Set ¶
func (flag *StringArrayFlag) Set(value string) error
Set adds the supplied string to the string array. If the string contains comma seperators, the string will be split before being added to the array.
func (*StringArrayFlag) String ¶
func (flag *StringArrayFlag) String() string
String retruns the string array as a comma seperated string.