Documentation ¶
Index ¶
- func Config(set *goflag.FlagSet, name string, usage string, opts ...ucfg.Option) *ucfg.Config
- func ConfigVar(set *goflag.FlagSet, def *ucfg.Config, name string, usage string, ...) *ucfg.Config
- type FileLoader
- type FlagValue
- func ConfigFiles(set *goflag.FlagSet, name string, usage string, ...) *FlagValue
- func ConfigFilesExts(set *goflag.FlagSet, name string, usage string, opts ...ucfg.Option) *FlagValue
- func ConfigFilesExtsVar(set *goflag.FlagSet, def *ucfg.Config, name string, usage string, ...) *FlagValue
- func ConfigFilesVar(set *goflag.FlagSet, def *ucfg.Config, name string, usage string, ...) *FlagValue
- func ConfigJSONFiles(set *goflag.FlagSet, name string, usage string, opts ...ucfg.Option) *FlagValue
- func ConfigJSONFilesVar(set *goflag.FlagSet, def *ucfg.Config, name string, usage string, ...) *FlagValue
- func ConfigYAMLFiles(set *goflag.FlagSet, name string, usage string, opts ...ucfg.Option) *FlagValue
- func ConfigYAMLFilesVar(set *goflag.FlagSet, def *ucfg.Config, name string, usage string, ...) *FlagValue
- func NewFlagFiles(cfg *ucfg.Config, extensions map[string]FileLoader, opts ...ucfg.Option) *FlagValue
- func NewFlagKeyValue(cfg *ucfg.Config, autoBool bool, opts ...ucfg.Option) *FlagValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FileLoader ¶
FileLoader is used by NewFlagFiles to define customer file loading functions for different file extensions.
type FlagValue ¶
type FlagValue struct {
// contains filtered or unexported fields
}
func ConfigFiles ¶
func ConfigFilesExts ¶
func ConfigFilesExtsVar ¶
func ConfigFilesVar ¶
func ConfigJSONFiles ¶
func ConfigJSONFilesVar ¶
func ConfigYAMLFiles ¶
func ConfigYAMLFilesVar ¶
func NewFlagFiles ¶
func NewFlagFiles( cfg *ucfg.Config, extensions map[string]FileLoader, opts ...ucfg.Option, ) *FlagValue
NewFlagFiles create a new flag, that will load external configurations file when being used. Configurations loaded from multiple files will be merged into one common Config object. If cfg is not nil, then the loaded configurations will be merged into cfg. The extensions parameter define custom file loaders for different file extensions. If extensions contains an entry with key "", then this loader will be used as default fallback.
func NewFlagKeyValue ¶
NewFlagKeyValue implements the flag.Value interface for capturing ucfg.Config settings from command line arguments. Configuration options follow the argument name and must be in the form of "key=value". Using 'D' as command line flag for example, options on command line must be given as:
-D key1=value -D key=value
Note: the space between command line option and key is required by the flag package to parse command line flags correctly.
Note: it's valid to use a key multiple times. If keys are used multiple times, values get overwritten. The last known value for some key will be stored in the generated configuration.
The type of value must be any of bool, uint, int, float, or string. Any kind of array or object syntax is not supported.
If autoBool is enabled (default if Config or ConfigVar is used), keys without value are converted to bool variable with value being true.