Documentation
¶
Index ¶
- Variables
- func AutomaticEnv()
- func SetEnvKeyReplacer(r *strings.Replacer)
- func SetEnvPrefix(in string)
- type BoolFlag
- type Command
- func (c *Command) AddCobraCommand(cmds ...*cobra.Command)
- func (c *Command) AddCommand(cmds ...*Command)
- func (c *Command) AddFlag(fs ...Flag) error
- func (c *Command) CobraCommands() []*cobra.Command
- func (c *Command) Commands() []*Command
- func (c *Command) RemoveCobraCommand(cmds ...*cobra.Command)
- func (c *Command) RemoveCommand(cmds ...*Command)
- type DurationFlag
- type Flag
- type Float32Flag
- type Float64Flag
- type Int32Flag
- type Int64Flag
- type IntFlag
- type StringFlag
- type StringSliceFlag
- type Uint32Flag
- type Uint64Flag
- type UintFlag
Constants ¶
This section is empty.
Variables ¶
var ( // UnderlineReplacer replace dash of underline UnderlineReplacer = strings.NewReplacer("-", "_") )
var ( // Viper global viper Viper = viper.New() )
Functions ¶
func AutomaticEnv ¶
func AutomaticEnv()
AutomaticEnv has Mamba check ENV variables for all. keys set in config, default & flags
func SetEnvKeyReplacer ¶
SetEnvKeyReplacer sets the strings.Replacer on the viper object Useful for mapping an environmental variable to a key that does not match it.
func SetEnvPrefix ¶
func SetEnvPrefix(in string)
SetEnvPrefix defines a prefix that ENVIRONMENT variables will use. E.g. if your prefix is "spf", the env registry will look for env variables that start with "SPF_". Only work for automatic env
Types ¶
type BoolFlag ¶
type BoolFlag struct {
// Name as it appears on command line
Name string
// one-letter abbreviated flag
Shorthand string
// help message
Usage string
// specify whether the flag is persistent
Persistent bool
// used by cobra.Command bash autocomple code
Annotations map[string][]string
// If this flag is deprecated, this string is the new or now thing to use
Deprecated string
// If the shorthand of this flag is deprecated, this string is the new or now thing to use
ShorthandDeprecated string
// used by cobra.Command to allow flags to be hidden from help/usage text
Hidden bool
// bind the flag to env key, you can use AutomaticEnv to bind all flags to env automatically
// if EnvKey is set, it will override the automatic generated env key
EnvKey string
// the default value
DefValue bool
// points to a variable in which to store the value of the flag
Destination *bool
}
BoolFlag is a flag of type bool
func (BoolFlag) IsPersistent ¶
IsPersistent specify whether the flag is persistent
type Command ¶
Command contains a cobra.Command
func (*Command) AddCobraCommand ¶
AddCobraCommand adds one or more cobra commands to this parent command.
func (*Command) AddCommand ¶
AddCommand adds one or more commands to this parent command.
func (*Command) CobraCommands ¶
CobraCommands returns a sorted slice of child cobra commands.
func (*Command) RemoveCobraCommand ¶
RemoveCobraCommand removes one or more cobra commands from a parent command.
func (*Command) RemoveCommand ¶
RemoveCommand removes one or more commands from a parent command.
type DurationFlag ¶
type DurationFlag struct {
// Name as it appears on command line
Name string
// one-letter abbreviated flag
Shorthand string
// help message
Usage string
// specify whether the flag is persistent
Persistent bool
// used by cobra.Command bash autocomple code
Annotations map[string][]string
// If this flag is deprecated, this string is the new or now thing to use
Deprecated string
// If the shorthand of this flag is deprecated, this string is the new or now thing to use
ShorthandDeprecated string
// used by cobra.Command to allow flags to be hidden from help/usage text
Hidden bool
// bind the flag to env key, you can use AutomaticEnv to bind all flags to env automatically
// if EnvKey is set, it will override the automatic generated env key
EnvKey string
// the default value
DefValue time.Duration
// points to a variable in which to store the value of the flag
Destination *time.Duration
}
DurationFlag is a flag of type time.Duration
func (DurationFlag) ApplyTo ¶
func (f DurationFlag) ApplyTo(fs *pflag.FlagSet) error
ApplyTo adds the flag to given FlagSet
func (DurationFlag) GetName ¶
func (f DurationFlag) GetName() string
GetName returns the flag's name
func (DurationFlag) IsPersistent ¶
func (f DurationFlag) IsPersistent() bool
IsPersistent specify whether the flag is persistent
type Flag ¶
type Flag interface {
// IsPersistent specify whether the flag is persistent
IsPersistent() bool
// GetName returns the flag's name
GetName() string
// ApplyTo adds the flag to a given FlagSet
ApplyTo(*pflag.FlagSet) error
}
Flag describes a flag interface
type Float32Flag ¶
type Float32Flag struct {
// Name as it appears on command line
Name string
// one-letter abbreviated flag
Shorthand string
// help message
Usage string
// specify whether the flag is persistent
Persistent bool
// used by cobra.Command bash autocomple code
Annotations map[string][]string
// If this flag is deprecated, this string is the new or now thing to use
Deprecated string
// If the shorthand of this flag is deprecated, this string is the new or now thing to use
ShorthandDeprecated string
// used by cobra.Command to allow flags to be hidden from help/usage text
Hidden bool
// bind the flag to env key, you can use AutomaticEnv to bind all flags to env automatically
// if EnvKey is set, it will override the automatic generated env key
EnvKey string
// the default value
DefValue float32
// points to a variable in which to store the value of the flag
Destination *float32
}
Float32Flag is a flag of type float32
func (Float32Flag) ApplyTo ¶
func (f Float32Flag) ApplyTo(fs *pflag.FlagSet) error
ApplyTo adds the flag to given FlagSet
func (Float32Flag) IsPersistent ¶
func (f Float32Flag) IsPersistent() bool
IsPersistent specify whether the flag is persistent
type Float64Flag ¶
type Float64Flag struct {
// Name as it appears on command line
Name string
// one-letter abbreviated flag
Shorthand string
// help message
Usage string
// specify whether the flag is persistent
Persistent bool
// used by cobra.Command bash autocomple code
Annotations map[string][]string
// If this flag is deprecated, this string is the new or now thing to use
Deprecated string
// If the shorthand of this flag is deprecated, this string is the new or now thing to use
ShorthandDeprecated string
// used by cobra.Command to allow flags to be hidden from help/usage text
Hidden bool
// bind the flag to env key, you can use AutomaticEnv to bind all flags to env automatically
// if EnvKey is set, it will override the automatic generated env key
EnvKey string
// the default value
DefValue float64
// points to a variable in which to store the value of the flag
Destination *float64
}
Float64Flag is a flag of type float64
func (Float64Flag) ApplyTo ¶
func (f Float64Flag) ApplyTo(fs *pflag.FlagSet) error
ApplyTo adds the flag to given FlagSet
func (Float64Flag) IsPersistent ¶
func (f Float64Flag) IsPersistent() bool
IsPersistent specify whether the flag is persistent
type Int32Flag ¶
type Int32Flag struct {
// Name as it appears on command line
Name string
// one-letter abbreviated flag
Shorthand string
// help message
Usage string
// specify whether the flag is persistent
Persistent bool
// used by cobra.Command bash autocomple code
Annotations map[string][]string
// If this flag is deprecated, this string is the new or now thing to use
Deprecated string
// If the shorthand of this flag is deprecated, this string is the new or now thing to use
ShorthandDeprecated string
// used by cobra.Command to allow flags to be hidden from help/usage text
Hidden bool
// bind the flag to env key, you can use AutomaticEnv to bind all flags to env automatically
// if EnvKey is set, it will override the automatic generated env key
EnvKey string
// the default value
DefValue int32
// points to a variable in which to store the value of the flag
Destination *int32
}
Int32Flag is a flag of type int32
func (Int32Flag) IsPersistent ¶
IsPersistent specify whether the flag is persistent
type Int64Flag ¶
type Int64Flag struct {
// Name as it appears on command line
Name string
// one-letter abbreviated flag
Shorthand string
// help message
Usage string
// specify whether the flag is persistent
Persistent bool
// used by cobra.Command bash autocomple code
Annotations map[string][]string
// If this flag is deprecated, this string is the new or now thing to use
Deprecated string
// If the shorthand of this flag is deprecated, this string is the new or now thing to use
ShorthandDeprecated string
// used by cobra.Command to allow flags to be hidden from help/usage text
Hidden bool
// bind the flag to env key, you can use AutomaticEnv to bind all flags to env automatically
// if EnvKey is set, it will override the automatic generated env key
EnvKey string
// the default value
DefValue int64
// points to a variable in which to store the value of the flag
Destination *int64
}
Int64Flag is a flag of type int64
func (Int64Flag) IsPersistent ¶
IsPersistent specify whether the flag is persistent
type IntFlag ¶
type IntFlag struct {
// Name as it appears on command line
Name string
// one-letter abbreviated flag
Shorthand string
// help message
Usage string
// specify whether the flag is persistent
Persistent bool
// used by cobra.Command bash autocomple code
Annotations map[string][]string
// If this flag is deprecated, this string is the new or now thing to use
Deprecated string
// If the shorthand of this flag is deprecated, this string is the new or now thing to use
ShorthandDeprecated string
// used by cobra.Command to allow flags to be hidden from help/usage text
Hidden bool
// bind the flag to env key, you can use AutomaticEnv to bind all flags to env automatically
// if EnvKey is set, it will override the automatic generated env key
EnvKey string
// the default value
DefValue int
// points to a variable in which to store the value of the flag
Destination *int
}
IntFlag is a flag of type int
func (IntFlag) IsPersistent ¶
IsPersistent specify whether the flag is persistent
type StringFlag ¶
type StringFlag struct {
// Name as it appears on command line
Name string
// one-letter abbreviated flag
Shorthand string
// help message
Usage string
// specify whether the flag is persistent
Persistent bool
// used by cobra.Command bash autocomple code
Annotations map[string][]string
// If this flag is deprecated, this string is the new or now thing to use
Deprecated string
// If the shorthand of this flag is deprecated, this string is the new or now thing to use
ShorthandDeprecated string
// used by cobra.Command to allow flags to be hidden from help/usage text
Hidden bool
// bind the flag to env key, you can use AutomaticEnv to bind all flags to env automatically
// if EnvKey is set, it will override the automatic generated env key
EnvKey string
// the default value
DefValue string
// points to a variable in which to store the value of the flag
Destination *string
}
StringFlag is a flag of type string
func (StringFlag) ApplyTo ¶
func (f StringFlag) ApplyTo(fs *pflag.FlagSet) error
ApplyTo adds the flag to given FlagSet
func (StringFlag) IsPersistent ¶
func (f StringFlag) IsPersistent() bool
IsPersistent specify whether the flag is persistent
type StringSliceFlag ¶
type StringSliceFlag struct {
// Name as it appears on command line
Name string
// one-letter abbreviated flag
Shorthand string
// help message
Usage string
// specify whether the flag is persistent
Persistent bool
// used by cobra.Command bash autocomple code
Annotations map[string][]string
// If this flag is deprecated, this string is the new or now thing to use
Deprecated string
// If the shorthand of this flag is deprecated, this string is the new or now thing to use
ShorthandDeprecated string
// used by cobra.Command to allow flags to be hidden from help/usage text
Hidden bool
// bind the flag to env key, you can use AutomaticEnv to bind all flags to env automatically
// if EnvKey is set, it will override the automatic generated env key
EnvKey string
// the default value
DefValue []string
// points to a variable in which to store the value of the flag
Destination *[]string
}
StringSliceFlag is a flag of type []string
func (StringSliceFlag) ApplyTo ¶
func (f StringSliceFlag) ApplyTo(fs *pflag.FlagSet) error
ApplyTo adds the flag to given FlagSet
func (StringSliceFlag) GetName ¶
func (f StringSliceFlag) GetName() string
GetName returns the flag's name
func (StringSliceFlag) IsPersistent ¶
func (f StringSliceFlag) IsPersistent() bool
IsPersistent specify whether the flag is persistent
type Uint32Flag ¶
type Uint32Flag struct {
// Name as it appears on command line
Name string
// one-letter abbreviated flag
Shorthand string
// help message
Usage string
// specify whether the flag is persistent
Persistent bool
// used by cobra.Command bash autocomple code
Annotations map[string][]string
// If this flag is deprecated, this string is the new or now thing to use
Deprecated string
// If the shorthand of this flag is deprecated, this string is the new or now thing to use
ShorthandDeprecated string
// used by cobra.Command to allow flags to be hidden from help/usage text
Hidden bool
// bind the flag to env key, you can use AutomaticEnv to bind all flags to env automatically
// if EnvKey is set, it will override the automatic generated env key
EnvKey string
// the default value
DefValue uint32
// points to a variable in which to store the value of the flag
Destination *uint32
}
Uint32Flag is a flag of type uint32
func (Uint32Flag) ApplyTo ¶
func (f Uint32Flag) ApplyTo(fs *pflag.FlagSet) error
ApplyTo adds the flag to given FlagSet
func (Uint32Flag) IsPersistent ¶
func (f Uint32Flag) IsPersistent() bool
IsPersistent specify whether the flag is persistent
type Uint64Flag ¶
type Uint64Flag struct {
// Name as it appears on command line
Name string
// one-letter abbreviated flag
Shorthand string
// help message
Usage string
// specify whether the flag is persistent
Persistent bool
// used by cobra.Command bash autocomple code
Annotations map[string][]string
// If this flag is deprecated, this string is the new or now thing to use
Deprecated string
// If the shorthand of this flag is deprecated, this string is the new or now thing to use
ShorthandDeprecated string
// used by cobra.Command to allow flags to be hidden from help/usage text
Hidden bool
// bind the flag to env key, you can use AutomaticEnv to bind all flags to env automatically
// if EnvKey is set, it will override the automatic generated env key
EnvKey string
// the default value
DefValue uint64
// points to a variable in which to store the value of the flag
Destination *uint64
}
Uint64Flag is a flag of type uint64
func (Uint64Flag) ApplyTo ¶
func (f Uint64Flag) ApplyTo(fs *pflag.FlagSet) error
ApplyTo adds the flag to given FlagSet
func (Uint64Flag) IsPersistent ¶
func (f Uint64Flag) IsPersistent() bool
IsPersistent specify whether the flag is persistent
type UintFlag ¶
type UintFlag struct {
// Name as it appears on command line
Name string
// one-letter abbreviated flag
Shorthand string
// help message
Usage string
// specify whether the flag is persistent
Persistent bool
// used by cobra.Command bash autocomple code
Annotations map[string][]string
// If this flag is deprecated, this string is the new or now thing to use
Deprecated string
// If the shorthand of this flag is deprecated, this string is the new or now thing to use
ShorthandDeprecated string
// used by cobra.Command to allow flags to be hidden from help/usage text
Hidden bool
// bind the flag to env key, you can use AutomaticEnv to bind all flags to env automatically
// if EnvKey is set, it will override the automatic generated env key
EnvKey string
// the default value
DefValue uint
// points to a variable in which to store the value of the flag
Destination *uint
}
UintFlag is a flag of type uint
func (UintFlag) IsPersistent ¶
IsPersistent specify whether the flag is persistent