Documentation ¶
Index ¶
- Variables
- func AddFieldByMappedOption(opts OptionValueProvider, oname string, config Config, ...) error
- func AddFieldByMappedOptionP(opts OptionValueProvider, p NameProvider, config Config, ...) error
- func AddFieldByOption(opts OptionValueProvider, oname string, config Config, names ...string) error
- func AddFieldByOptionP(opts OptionValueProvider, p NameProvider, config Config, names ...string) error
- func AddGroups(list []string, groups ...string) []string
- func AddPrefix(prefix string, values ...string) []string
- func FormatConfigOptions(handler ConfigOptionTypeSetHandler) string
- func GetField(config Config, names ...string) (interface{}, error)
- func OptionSpec(otype ConfigOptionType, args ...string) _OptionSpec
- func OptionString(option ConfigOptionType) string
- func OptionStrings(types ...ConfigOptionType) []string
- func ParseOptionsFor(flags *pflag.FlagSet, specs ..._OptionSpec) error
- func SetField(config Config, value interface{}, names ...string) error
- type BoolOption
- type BoolOptionType
- type BytesOption
- type BytesOptionType
- type Config
- type ConfigAdder
- type ConfigHandler
- type ConfigOptionType
- func NewBoolOptionType(name string, description string) ConfigOptionType
- func NewBytesOptionType(name string, description string) ConfigOptionType
- func NewIntOptionType(name string, description string) ConfigOptionType
- func NewPathArrayOptionType(name string, description string) ConfigOptionType
- func NewPathOptionType(name string, description string) ConfigOptionType
- func NewStringArrayOptionType(name string, description string) ConfigOptionType
- func NewStringMapOptionType(name string, description string) ConfigOptionType
- func NewStringOptionType(name string, description string) ConfigOptionType
- func NewStringSliceMapColonOptionType(name string, description string) ConfigOptionType
- func NewStringSliceMapOptionType(name string, description string) ConfigOptionType
- func NewValueMapOptionType(name string, description string) ConfigOptionType
- func NewValueMapYAMLOptionType(name string, description string) ConfigOptionType
- func NewYAMLOptionType(name string, description string) ConfigOptionType
- type ConfigOptionTypeSet
- type ConfigOptionTypeSetHandler
- type ConfigOptions
- type ConfigProvider
- type ConfigTypeOptionSetConfigProvider
- func NewPlainConfigProvider(name string, adder ConfigAdder, types ...ConfigOptionType) ConfigTypeOptionSetConfigProvider
- func NewTypedConfigProvider(name string, desc, typeOption string, acceptUnknown ...bool) ConfigTypeOptionSetConfigProvider
- func NewTypedConfigProviderBase(name string, desc string, prov TypeNameProvider, acceptUnknown bool, ...) ConfigTypeOptionSetConfigProvider
- type ExplicitlyTypedConfigTypeOptionSetConfigProvider
- type Filter
- type IntOption
- type IntOptionType
- type NameProvider
- type Option
- type OptionBase
- type OptionName
- type OptionValueProvider
- type PathArrayOption
- type PathArrayOptionType
- type PathOption
- type PathOptionType
- type StringArrayOption
- type StringArrayOptionType
- type StringMapOption
- type StringMapOptionType
- type StringOption
- type StringOptionType
- type StringSliceMapColonOption
- type StringSliceMapColonOptionType
- type StringSliceMapOption
- type StringSliceMapOptionType
- type TypeNameProvider
- type TypeOptionBase
- type ValueMapOption
- type ValueMapOptionType
- type ValueMapYAMLOption
- type ValueMapYAMLOptionType
- type YAMLOption
- type YAMLOptionType
Constants ¶
This section is empty.
Variables ¶
var NopConfigHandler = NewNopConfigHandler()
NopConfigHandler is a dummy config handler doing nothing.
Functions ¶
func AddFieldByMappedOption ¶
func AddFieldByMappedOptionP ¶
func AddFieldByMappedOptionP(opts OptionValueProvider, p NameProvider, config Config, mapper func(interface{}) (interface{}, error), names ...string) error
func AddFieldByOption ¶
func AddFieldByOption(opts OptionValueProvider, oname string, config Config, names ...string) error
AddFieldByOption sets the specified target field with the option value, if given. If no target field is specified the name of the option is used.
func AddFieldByOptionP ¶
func AddFieldByOptionP(opts OptionValueProvider, p NameProvider, config Config, names ...string) error
AddFieldByOptionP sets the specified target field with the option value, if given. The option is specified by a name provider instead of its name. If no target field is specified the name of the option is used.
func FormatConfigOptions ¶ added in v0.3.0
func FormatConfigOptions(handler ConfigOptionTypeSetHandler) string
func OptionSpec ¶ added in v0.7.0
func OptionSpec(otype ConfigOptionType, args ...string) _OptionSpec
func OptionString ¶ added in v0.7.0
func OptionString(option ConfigOptionType) string
func OptionStrings ¶ added in v0.7.0
func OptionStrings(types ...ConfigOptionType) []string
func ParseOptionsFor ¶ added in v0.7.0
Types ¶
type BoolOption ¶
type BoolOption struct { OptionBase // contains filtered or unexported fields }
func (*BoolOption) AddFlags ¶
func (o *BoolOption) AddFlags(fs *pflag.FlagSet)
func (*BoolOption) Value ¶
func (o *BoolOption) Value() interface{}
type BoolOptionType ¶
type BoolOptionType struct {
TypeOptionBase
}
func (*BoolOptionType) Create ¶
func (s *BoolOptionType) Create() Option
func (*BoolOptionType) Equal ¶
func (s *BoolOptionType) Equal(optionType ConfigOptionType) bool
type BytesOption ¶
type BytesOption struct { OptionBase // contains filtered or unexported fields }
func (*BytesOption) AddFlags ¶
func (o *BytesOption) AddFlags(fs *pflag.FlagSet)
func (*BytesOption) Value ¶
func (o *BytesOption) Value() interface{}
type BytesOptionType ¶
type BytesOptionType struct {
TypeOptionBase
}
func (*BytesOptionType) Create ¶
func (s *BytesOptionType) Create() Option
func (*BytesOptionType) Equal ¶
func (s *BytesOptionType) Equal(optionType ConfigOptionType) bool
type Config ¶
type Config = map[string]interface{}
Config is a generic structured config stored in a string map.
type ConfigAdder ¶
type ConfigAdder func(options ConfigOptions, config Config) error
ConfigAdder is used to incorporate a partial config into an existing one.
func ComposedAdder ¶
func ComposedAdder(adders ...ConfigAdder) ConfigAdder
func (ConfigAdder) ApplyConfig ¶
func (c ConfigAdder) ApplyConfig(options ConfigOptions, config Config) error
type ConfigHandler ¶
type ConfigHandler interface {
ApplyConfig(options ConfigOptions, config Config) error
}
ConfigHandler describes the ConfigAdder functionality.
func NewNopConfigHandler ¶
func NewNopConfigHandler() ConfigHandler
type ConfigOptionType ¶
type ConfigOptionType interface { GetName() string GetDescription() string Create() Option Equal(optionType ConfigOptionType) bool }
func NewBoolOptionType ¶
func NewBoolOptionType(name string, description string) ConfigOptionType
func NewBytesOptionType ¶
func NewBytesOptionType(name string, description string) ConfigOptionType
func NewIntOptionType ¶
func NewIntOptionType(name string, description string) ConfigOptionType
func NewPathArrayOptionType ¶ added in v0.7.0
func NewPathArrayOptionType(name string, description string) ConfigOptionType
func NewPathOptionType ¶ added in v0.7.0
func NewPathOptionType(name string, description string) ConfigOptionType
func NewStringArrayOptionType ¶
func NewStringArrayOptionType(name string, description string) ConfigOptionType
func NewStringMapOptionType ¶
func NewStringMapOptionType(name string, description string) ConfigOptionType
func NewStringOptionType ¶
func NewStringOptionType(name string, description string) ConfigOptionType
func NewStringSliceMapColonOptionType ¶ added in v0.8.0
func NewStringSliceMapColonOptionType(name string, description string) ConfigOptionType
func NewStringSliceMapOptionType ¶ added in v0.8.0
func NewStringSliceMapOptionType(name string, description string) ConfigOptionType
func NewValueMapOptionType ¶
func NewValueMapOptionType(name string, description string) ConfigOptionType
func NewValueMapYAMLOptionType ¶
func NewValueMapYAMLOptionType(name string, description string) ConfigOptionType
func NewYAMLOptionType ¶
func NewYAMLOptionType(name string, description string) ConfigOptionType
type ConfigOptionTypeSet ¶
type ConfigOptionTypeSet interface { AddGroups(groups ...string) GetName() string Size() int OptionTypes() []ConfigOptionType OptionTypeNames() []string HasOptionType(name string) bool GetOptionType(name string) ConfigOptionType GetTypeSet(name string) ConfigOptionTypeSet OptionTypeSets() []ConfigOptionTypeSet AddOptionType(ConfigOptionType) error AddTypeSet(ConfigOptionTypeSet) error AddAll(o ConfigOptionTypeSet) (duplicated ConfigOptionTypeSet, err error) Close(funcs ...func([]ConfigOptionType) error) error CreateOptions() ConfigOptions AddGroupsToOption(o Option) }
func NewConfigOptionTypeSet ¶ added in v0.4.1
func NewConfigOptionTypeSet(name string, types ...ConfigOptionType) ConfigOptionTypeSet
type ConfigOptionTypeSetHandler ¶
type ConfigOptionTypeSetHandler interface { ConfigOptionTypeSet ConfigHandler }
ConfigOptionTypeSetHandler describes a ConfigOptionTypeSet, which also provides the possibility to provide config.
func NewConfigOptionTypeSetHandler ¶
func NewConfigOptionTypeSetHandler(name string, adder ConfigAdder, types ...ConfigOptionType) ConfigOptionTypeSetHandler
NewConfigOptionTypeSetHandler creates a new ConfigOptionTypeSetHandler.
type ConfigOptions ¶
type ConfigOptions interface { AddTypeSetGroupsToOptions(set ConfigOptionTypeSet) AddFlags(fs *pflag.FlagSet) Options() []Option Names() []string Size() int HasOption(name string) bool Check(set ConfigOptionTypeSet, desc string) error GetValue(name string) (interface{}, bool) Changed(names ...string) bool FilterBy(Filter) ConfigOptions }
ConfigOptions is a set of arbitrary command line options. This set can be added to a pflag.FlagSet. After evaluation of the flag set against a set of arguments it provides information about the actual value and the changed state.
func NewOptions ¶
func NewOptions(opts []Option) ConfigOptions
func NewOptionsByList ¶ added in v0.7.0
func NewOptionsByList(opts ...Option) ConfigOptions
type ConfigProvider ¶
type ConfigProvider interface { CreateOptions() ConfigOptions GetConfigFor(opts ConfigOptions) (Config, error) }
type ConfigTypeOptionSetConfigProvider ¶
type ConfigTypeOptionSetConfigProvider interface { ConfigProvider ConfigOptionTypeSet GetPlainOptionType() ConfigOptionType GetTypeOptionType() ConfigOptionType IsExplicitlySelected(opts ConfigOptions) bool }
func NewPlainConfigProvider ¶
func NewPlainConfigProvider(name string, adder ConfigAdder, types ...ConfigOptionType) ConfigTypeOptionSetConfigProvider
func NewTypedConfigProvider ¶
func NewTypedConfigProvider(name string, desc, typeOption string, acceptUnknown ...bool) ConfigTypeOptionSetConfigProvider
func NewTypedConfigProviderBase ¶ added in v0.4.1
func NewTypedConfigProviderBase(name string, desc string, prov TypeNameProvider, acceptUnknown bool, types ...ConfigOptionType) ConfigTypeOptionSetConfigProvider
type ExplicitlyTypedConfigTypeOptionSetConfigProvider ¶ added in v0.4.1
type ExplicitlyTypedConfigTypeOptionSetConfigProvider interface { ConfigTypeOptionSetConfigProvider SetTypeName(n string) }
func NewExplicitlyTypedConfigProvider ¶ added in v0.4.1
func NewExplicitlyTypedConfigProvider(name string, desc string, acceptUnknown ...bool) ExplicitlyTypedConfigTypeOptionSetConfigProvider
type IntOption ¶
type IntOption struct { OptionBase // contains filtered or unexported fields }
type IntOptionType ¶
type IntOptionType struct {
TypeOptionBase
}
func (*IntOptionType) Create ¶
func (s *IntOptionType) Create() Option
func (*IntOptionType) Equal ¶
func (s *IntOptionType) Equal(optionType ConfigOptionType) bool
type NameProvider ¶
type NameProvider interface {
GetName() string
}
type OptionBase ¶
type OptionBase struct {
// contains filtered or unexported fields
}
func NewOptionBase ¶
func NewOptionBase(otyp ConfigOptionType) OptionBase
func (*OptionBase) AddGroups ¶
func (b *OptionBase) AddGroups(groups ...string)
func (*OptionBase) Changed ¶
func (b *OptionBase) Changed() bool
func (*OptionBase) Description ¶
func (b *OptionBase) Description() string
func (*OptionBase) GetName ¶
func (b *OptionBase) GetName() string
func (*OptionBase) TweakFlag ¶
func (b *OptionBase) TweakFlag(f *pflag.Flag)
func (*OptionBase) Type ¶
func (b *OptionBase) Type() ConfigOptionType
type OptionName ¶
type OptionName string
func (OptionName) GetName ¶
func (n OptionName) GetName() string
type OptionValueProvider ¶
OptionValueProvider provides values for named options.
type PathArrayOption ¶ added in v0.7.0
type PathArrayOption struct { OptionBase // contains filtered or unexported fields }
func (*PathArrayOption) AddFlags ¶ added in v0.7.0
func (o *PathArrayOption) AddFlags(fs *pflag.FlagSet)
func (*PathArrayOption) Value ¶ added in v0.7.0
func (o *PathArrayOption) Value() interface{}
type PathArrayOptionType ¶ added in v0.7.0
type PathArrayOptionType struct {
TypeOptionBase
}
func (*PathArrayOptionType) Create ¶ added in v0.7.0
func (s *PathArrayOptionType) Create() Option
func (*PathArrayOptionType) Equal ¶ added in v0.7.0
func (s *PathArrayOptionType) Equal(optionType ConfigOptionType) bool
type PathOption ¶ added in v0.7.0
type PathOption struct { OptionBase // contains filtered or unexported fields }
func (*PathOption) AddFlags ¶ added in v0.7.0
func (o *PathOption) AddFlags(fs *pflag.FlagSet)
func (*PathOption) Value ¶ added in v0.7.0
func (o *PathOption) Value() interface{}
type PathOptionType ¶ added in v0.7.0
type PathOptionType struct {
TypeOptionBase
}
func (*PathOptionType) Create ¶ added in v0.7.0
func (s *PathOptionType) Create() Option
func (*PathOptionType) Equal ¶ added in v0.7.0
func (s *PathOptionType) Equal(optionType ConfigOptionType) bool
type StringArrayOption ¶
type StringArrayOption struct { OptionBase // contains filtered or unexported fields }
func (*StringArrayOption) AddFlags ¶
func (o *StringArrayOption) AddFlags(fs *pflag.FlagSet)
func (*StringArrayOption) Value ¶
func (o *StringArrayOption) Value() interface{}
type StringArrayOptionType ¶
type StringArrayOptionType struct {
TypeOptionBase
}
func (*StringArrayOptionType) Create ¶
func (s *StringArrayOptionType) Create() Option
func (*StringArrayOptionType) Equal ¶
func (s *StringArrayOptionType) Equal(optionType ConfigOptionType) bool
type StringMapOption ¶
type StringMapOption struct { OptionBase // contains filtered or unexported fields }
func (*StringMapOption) AddFlags ¶
func (o *StringMapOption) AddFlags(fs *pflag.FlagSet)
func (*StringMapOption) Value ¶
func (o *StringMapOption) Value() interface{}
type StringMapOptionType ¶
type StringMapOptionType struct {
TypeOptionBase
}
func (*StringMapOptionType) Create ¶
func (s *StringMapOptionType) Create() Option
func (*StringMapOptionType) Equal ¶
func (s *StringMapOptionType) Equal(optionType ConfigOptionType) bool
type StringOption ¶
type StringOption struct { OptionBase // contains filtered or unexported fields }
func (*StringOption) AddFlags ¶
func (o *StringOption) AddFlags(fs *pflag.FlagSet)
func (*StringOption) Value ¶
func (o *StringOption) Value() interface{}
type StringOptionType ¶
type StringOptionType struct {
TypeOptionBase
}
func (*StringOptionType) Create ¶
func (s *StringOptionType) Create() Option
func (*StringOptionType) Equal ¶
func (s *StringOptionType) Equal(optionType ConfigOptionType) bool
type StringSliceMapColonOption ¶ added in v0.8.0
type StringSliceMapColonOption struct { OptionBase // contains filtered or unexported fields }
func (*StringSliceMapColonOption) AddFlags ¶ added in v0.8.0
func (o *StringSliceMapColonOption) AddFlags(fs *pflag.FlagSet)
func (*StringSliceMapColonOption) Value ¶ added in v0.8.0
func (o *StringSliceMapColonOption) Value() interface{}
type StringSliceMapColonOptionType ¶ added in v0.8.0
type StringSliceMapColonOptionType struct {
TypeOptionBase
}
func (*StringSliceMapColonOptionType) Create ¶ added in v0.8.0
func (s *StringSliceMapColonOptionType) Create() Option
func (*StringSliceMapColonOptionType) Equal ¶ added in v0.8.0
func (s *StringSliceMapColonOptionType) Equal(optionType ConfigOptionType) bool
type StringSliceMapOption ¶ added in v0.8.0
type StringSliceMapOption struct { OptionBase // contains filtered or unexported fields }
func (*StringSliceMapOption) AddFlags ¶ added in v0.8.0
func (o *StringSliceMapOption) AddFlags(fs *pflag.FlagSet)
func (*StringSliceMapOption) Value ¶ added in v0.8.0
func (o *StringSliceMapOption) Value() interface{}
type StringSliceMapOptionType ¶ added in v0.8.0
type StringSliceMapOptionType struct {
TypeOptionBase
}
func (*StringSliceMapOptionType) Create ¶ added in v0.8.0
func (s *StringSliceMapOptionType) Create() Option
func (*StringSliceMapOptionType) Equal ¶ added in v0.8.0
func (s *StringSliceMapOptionType) Equal(optionType ConfigOptionType) bool
type TypeNameProvider ¶ added in v0.4.1
type TypeNameProvider func(opts ConfigOptions) (string, error)
func TypeNameProviderFromOptions ¶ added in v0.4.1
func TypeNameProviderFromOptions(name string) TypeNameProvider
type TypeOptionBase ¶
type TypeOptionBase struct {
// contains filtered or unexported fields
}
func (*TypeOptionBase) GetDescription ¶
func (b *TypeOptionBase) GetDescription() string
func (*TypeOptionBase) GetName ¶
func (b *TypeOptionBase) GetName() string
type ValueMapOption ¶
type ValueMapOption struct { OptionBase // contains filtered or unexported fields }
func (*ValueMapOption) AddFlags ¶
func (o *ValueMapOption) AddFlags(fs *pflag.FlagSet)
func (*ValueMapOption) Value ¶
func (o *ValueMapOption) Value() interface{}
type ValueMapOptionType ¶
type ValueMapOptionType struct {
TypeOptionBase
}
func (*ValueMapOptionType) Create ¶
func (s *ValueMapOptionType) Create() Option
func (*ValueMapOptionType) Equal ¶
func (s *ValueMapOptionType) Equal(optionType ConfigOptionType) bool
type ValueMapYAMLOption ¶
type ValueMapYAMLOption struct { OptionBase // contains filtered or unexported fields }
func (*ValueMapYAMLOption) AddFlags ¶
func (o *ValueMapYAMLOption) AddFlags(fs *pflag.FlagSet)
func (*ValueMapYAMLOption) Value ¶
func (o *ValueMapYAMLOption) Value() interface{}
type ValueMapYAMLOptionType ¶
type ValueMapYAMLOptionType struct {
TypeOptionBase
}
func (*ValueMapYAMLOptionType) Create ¶
func (s *ValueMapYAMLOptionType) Create() Option
func (*ValueMapYAMLOptionType) Equal ¶
func (s *ValueMapYAMLOptionType) Equal(optionType ConfigOptionType) bool
type YAMLOption ¶
type YAMLOption struct { OptionBase // contains filtered or unexported fields }
func (*YAMLOption) AddFlags ¶
func (o *YAMLOption) AddFlags(fs *pflag.FlagSet)
func (*YAMLOption) Value ¶
func (o *YAMLOption) Value() interface{}
type YAMLOptionType ¶
type YAMLOptionType struct {
TypeOptionBase
}
func (*YAMLOptionType) Create ¶
func (s *YAMLOptionType) Create() Option
func (*YAMLOptionType) Equal ¶
func (s *YAMLOptionType) Equal(optionType ConfigOptionType) bool
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package flagsetscheme provides a runtime.TypeScheme with support for command line option sets for the described object types.
|
Package flagsetscheme provides a runtime.TypeScheme with support for command line option sets for the described object types. |