Versions in this module Expand all Collapse all v0 v0.2.0 Jun 15, 2020 Changes in this version + var BoolOption = optionTypeImpl(tBoolOption) + var DurationOption = optionTypeImpl(tDurationOption) + var IntOption = optionTypeImpl(tIntOption) + var StringArrayOption = optionTypeImpl(tStringArrayOption) + var StringOption = optionTypeImpl(tStringOption) + var UintOption = optionTypeImpl(tUintOption) + func IdenityStringMapper(s string) string + func MapToArguments(prefix string, flags *pflag.FlagSet, data map[string]interface{}) ([]string, error) + func MergeConfig(yaml []byte, flags *pflag.FlagSet, override bool) error + func MergeConfigFile(fileName string, flags *pflag.FlagSet, override bool) error + func MergeFlags(flags *pflag.FlagSet, args []string, override bool) error + func ParseConfig(bytes []byte, flags *pflag.FlagSet) ([]string, error) + func Print(log Writer, gap string, opts Options) + func PrintfWriter(msgfmt string, args ...interface{}) + func ReadConfigFile(name string, flags *pflag.FlagSet) ([]string, error) + type ArbitraryOption struct + Default interface{} + Description string + FlagSet *pflag.FlagSet + Name string + Target interface{} + Type OptionType + func (this *ArbitraryOption) AddToCommand(cmd *cobra.Command) + func (this *ArbitraryOption) BoolValue() bool + func (this *ArbitraryOption) Changed() bool + func (this *ArbitraryOption) DurationValue() time.Duration + func (this *ArbitraryOption) Flag() *pflag.Flag + func (this *ArbitraryOption) IntValue() int + func (this *ArbitraryOption) IsArray() bool + func (this *ArbitraryOption) IsSlice() bool + func (this *ArbitraryOption) StringArray() []string + func (this *ArbitraryOption) StringValue() string + func (this *ArbitraryOption) UintValue() uint + func (this *ArbitraryOption) Value() interface{} + type DefaultOptionSet struct + func NewDefaultOptionSet(name, prefix string) *DefaultOptionSet + func (this *DefaultOptionSet) AddOption(otype OptionType, target interface{}, name, short string, def interface{}, ...) interface{} + func (this *DefaultOptionSet) AddOptionsToSet(set OptionSet) + func (this *DefaultOptionSet) AddRenamedOption(opt *ArbitraryOption, name, short string, desc string) interface{} + func (this *DefaultOptionSet) AddSource(key string, src OptionSource) + func (this *DefaultOptionSet) AddToCommand(cmd *cobra.Command) + func (this *DefaultOptionSet) AddToFlags(flags *pflag.FlagSet) + func (this *DefaultOptionSet) Complete() + func (this *DefaultOptionSet) Evaluate() error + func (this *DefaultOptionSet) GetOption(name string) *ArbitraryOption + func (this *DefaultOptionSet) GetSource(key string) OptionSource + func (this *DefaultOptionSet) Name() string + func (this *DefaultOptionSet) Prefix() string + func (this *DefaultOptionSet) SetValidator(v OptionValidator) + func (this *DefaultOptionSet) VisitOptions(f OptionVisitor) + func (this *DefaultOptionSet) VisitSources(f OptionSourceVisitor) + type GenericOptionSource struct + func NewGenericOptionSource(name, prefix string, descmapper StringMapper) *GenericOptionSource + func (this *GenericOptionSource) AddBoolOption(kind OptionKind, target *bool, name, short string, def bool, desc string) *bool + func (this *GenericOptionSource) AddDurationOption(kind OptionKind, target *time.Duration, name, short string, def time.Duration, ...) *time.Duration + func (this *GenericOptionSource) AddIntOption(kind OptionKind, target *int, name, short string, def int, desc string) *int + func (this *GenericOptionSource) AddOption(kind OptionKind, otype OptionType, target interface{}, name, short string, ...) interface{} + func (this *GenericOptionSource) AddOptionsToSet(set OptionSet) + func (this *GenericOptionSource) AddStringArrayOption(kind OptionKind, target *[]string, name, short string, def []string, ...) *[]string + func (this *GenericOptionSource) AddStringOption(kind OptionKind, target *string, name, short string, def string, desc string) *string + func (this *GenericOptionSource) AddUintOption(kind OptionKind, target *uint, name, short string, def uint, desc string) *uint + func (this *GenericOptionSource) Complete() + func (this *GenericOptionSource) Evaluate() error + func (this *GenericOptionSource) Flat() OptionSet + func (this *GenericOptionSource) GetOption(name string) *ArbitraryOption + func (this *GenericOptionSource) GetSource(name string) OptionSource + func (this *GenericOptionSource) Name() string + func (this *GenericOptionSource) Prefix() string + func (this *GenericOptionSource) Prefixed() OptionSet + func (this *GenericOptionSource) PrefixedShared() OptionSet + func (this *GenericOptionSource) Shared() OptionSet + func (this *GenericOptionSource) VisitOptions(f OptionVisitor) + func (this *GenericOptionSource) VisitSources(f OptionSourceVisitor) + type OptionCompleter interface + Complete func() + type OptionEvaluator interface + Evaluate func() error + type OptionGroup interface + type OptionKind func(t *GenericOptionSource) OptionSet + type OptionSet interface + AddBoolOption func(target *bool, name, short string, def bool, desc string) *bool + AddDurationOption func(target *time.Duration, name, short string, def time.Duration, desc string) *time.Duration + AddIntOption func(target *int, name, short string, def int, desc string) *int + AddOption func(otype OptionType, target interface{}, name, short string, def interface{}, ...) interface{} + AddRenamedOption func(opt *ArbitraryOption, name, short string, desc string) interface{} + AddStringArrayOption func(target *[]string, name, short string, def []string, desc string) *[]string + AddStringOption func(target *string, name, short, def string, desc string) *string + AddToFlags func(flags *pflag.FlagSet) + AddUintOption func(target *uint, name, short string, def uint, desc string) *uint + func Flat(t *GenericOptionSource) OptionSet + func Prefixed(t *GenericOptionSource) OptionSet + func PrefixedShared(t *GenericOptionSource) OptionSet + func Shared(t *GenericOptionSource) OptionSet + type OptionSetProxy func(otype OptionType, target interface{}, name, short string, def interface{}, ...) interface + func (p OptionSetProxy) AddBoolOption(target *bool, name, short string, def bool, desc string) *bool + func (p OptionSetProxy) AddDurationOption(target *time.Duration, name, short string, def time.Duration, desc string) *time.Duration + func (p OptionSetProxy) AddIntOption(target *int, name, short string, def int, desc string) *int + func (p OptionSetProxy) AddOption(otype OptionType, target interface{}, name, short string, def interface{}, ...) interface{} + func (p OptionSetProxy) AddStringArrayOption(target *[]string, name, short string, def []string, desc string) *[]string + func (p OptionSetProxy) AddStringOption(target *string, name, short string, def string, desc string) *string + func (p OptionSetProxy) AddUintOption(target *uint, name, short string, def uint, desc string) *uint + type OptionSource interface + AddOptionsToSet func(set OptionSet) + type OptionSourceGroup interface + AddSource func(key string, src OptionSource) + type OptionSourceSource interface + GetSource func(key string) OptionSource + Name func() string + VisitSources func(OptionSourceVisitor) + type OptionSourceVisitor func(string, OptionSource) bool + type OptionType interface + AddToFlags func(flags *pflag.FlagSet, target interface{}, name, short string, def interface{}, ...) interface{} + type OptionValidator func(name string, set OptionSet) + type OptionVisitor func(*ArbitraryOption) bool + type Options interface + GetOption func(name string) *ArbitraryOption + VisitOptions func(OptionVisitor) + type SharedOptionSet struct + func NewSharedOptionSet(name, prefix string, descMapper StringMapper) *SharedOptionSet + func (this *SharedOptionSet) AddOptionsToSet(set OptionSet) + func (this *SharedOptionSet) Evaluate() error + func (this *SharedOptionSet) Unshare(name string) + type StringMapper func(string) string + type Validatable interface + SetValidator func(validator OptionValidator) + type Writer func(msgfmt string, args ...interface{})