Documentation ¶
Index ¶
- Variables
- func GetConfigFlagSet(args []string, cfg interface{}) (*flag.FlagSet, error)
- type Configuration
- type ConfigurationOption
- func NewOptionBool(name string, options ...ConfigurationOptions) ConfigurationOption
- func NewOptionComplex(name string, defaultValue interface{}, options ...ConfigurationOptions) ConfigurationOption
- func NewOptionFloat(name string, options ...ConfigurationOptions) ConfigurationOption
- func NewOptionInt(name string, options ...ConfigurationOptions) ConfigurationOption
- func NewOptionString(name string, options ...ConfigurationOptions) ConfigurationOption
- type ConfigurationOptions
- type Decoder
- type Setter
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidConfig = errors.New("cfg must be a struct pointer")
ErrInvalidConfig is the default error message if you don't pass the cfg argument as a struct pointer to GetConfigFlagSet
Functions ¶
func GetConfigFlagSet ¶
GetConfigFlagSet takes in the args from the cli and a struct pointer to the struct it will parse. It will look at the tags to determine what keys and areas to look for. The base use case is that you can pass a struct pointer and it will use the envconfig: tag to find the matching environment variable and that can be overridden at launch with a command line flag. The flag will be the same as the envconfig: if not specified, or can be changed with the envcli: tag
Types ¶
type Configuration ¶ added in v1.1.0
type Configuration struct {
Config interface{}
}
Configuration is returned by BuildConfig as an unknown struct to read valued from after initial creation
func BuildConfig ¶ added in v1.1.0
func BuildConfig(options ...ConfigurationOption) Configuration
BuildConfig takes a variable amount of ConfigurationOption arguments and uses them to build a struct. This allows you to be very specific in how to build the struct if you don't want to have a struct at the top of your file and want to build it as you go
func (*Configuration) GetBool ¶ added in v1.1.0
func (c *Configuration) GetBool(name string) bool
GetBool gets a boolean value from the key that matches the provided name in the Configuration
func (*Configuration) GetComplex ¶ added in v1.1.0
func (c *Configuration) GetComplex(name string) interface{}
GetComplex gets an interface value from the key that matches the provided name in the Configuration. This assumes you know what you're asking for and how to cast the result
func (*Configuration) GetFloat64 ¶ added in v1.1.0
func (c *Configuration) GetFloat64(name string) float64
GetFloat64 gets a float64 value from the key that matches the provided name in the Configuration
func (*Configuration) GetInt64 ¶ added in v1.1.0
func (c *Configuration) GetInt64(name string) int64
GetInt64 gets a int64 value from the key that matches the provided name in the Configuration
func (*Configuration) GetString ¶ added in v1.1.0
func (c *Configuration) GetString(name string) string
GetString gets a string value from the key that matches the provided name in the Configuration
type ConfigurationOption ¶ added in v1.1.0
type ConfigurationOption struct {
// contains filtered or unexported fields
}
ConfigurationOption is the extensible struct used to build up a struct field that will be returned as Configuration.Config
func NewOptionBool ¶ added in v1.1.0
func NewOptionBool(name string, options ...ConfigurationOptions) ConfigurationOption
NewOptionBool creates a new bool struct field with the given name and options. When considering the name, remember Go's syntax of an upper-case first letter
func NewOptionComplex ¶ added in v1.1.0
func NewOptionComplex(name string, defaultValue interface{}, options ...ConfigurationOptions) ConfigurationOption
NewOptionComplex creates a new interface{} struct field with the given name and options. When considering the name, remember Go's syntax of an upper-case first letter
func NewOptionFloat ¶ added in v1.1.0
func NewOptionFloat(name string, options ...ConfigurationOptions) ConfigurationOption
NewOptionFloat creates a new float64 struct field with the given name and options. When considering the name, remember Go's syntax of an upper-case first letter
func NewOptionInt ¶ added in v1.1.0
func NewOptionInt(name string, options ...ConfigurationOptions) ConfigurationOption
NewOptionInt creates a new int64 struct field with the given name and options. When considering the name, remember Go's syntax of an upper-case first letter
func NewOptionString ¶ added in v1.1.0
func NewOptionString(name string, options ...ConfigurationOptions) ConfigurationOption
NewOptionString creates a new string struct field with the given name and options. When considering the name, remember Go's syntax of an upper-case first letter
type ConfigurationOptions ¶ added in v1.1.0
type ConfigurationOptions func(*ConfigurationOption)
ConfigurationOptions function used to build the individual ConfigurationOption field
func OptionCLIName ¶ added in v1.1.0
func OptionCLIName(name string) ConfigurationOptions
OptionCLIName used to add a envcli: tag to a struct field; will also assume that there is a cli flag
func OptionCLIUsage ¶ added in v1.1.0
func OptionCLIUsage(usage string) ConfigurationOptions
OptionCLIUsage used to add a clidesc: tag to a struct field; will also assume that there is a cli flag
func OptionENVName ¶ added in v1.1.0
func OptionENVName(name string) ConfigurationOptions
OptionENVName used to add a envconfig: tag to a struct field
func OptionJSONName ¶ added in v1.1.0
func OptionJSONName(name string) ConfigurationOptions
OptionJSONName used to add a json: tag to a struct field