Documentation ¶
Index ¶
- Variables
- func CanonicalFieldName(sf reflect.StructField) string
- func FindParentPaths(homedir, cwd, fileName string) []string
- func MakeMergeStruct(structs ...interface{}) interface{}
- func Merge(dst, src interface{}) error
- type BoolOption
- type ByteOption
- type ChangeSetFunc
- type Complex128Option
- type Complex64Option
- type ConfigOptions
- type ConfigSource
- type CreateOption
- func WithApplyChangeSet(apply ChangeSetFunc) CreateOption
- func WithConfigDir(dir string) CreateOption
- func WithCwd(cwd string) CreateOption
- func WithEnvPrefix(env string) CreateOption
- func WithFilterOut(filt FilterOut) CreateOption
- func WithHome(home string) CreateOption
- func WithPreProcessor(pp PreProcessor) CreateOption
- func WithoutExec() CreateOption
- type ErrorOption
- type FigTree
- func (f *FigTree) Copy() *FigTree
- func (f *FigTree) FindParentPaths(fileName string) []string
- func (f *FigTree) LoadAllConfigSources(sources []ConfigSource, options interface{}) error
- func (f *FigTree) LoadAllConfigs(configFile string, options interface{}) error
- func (f *FigTree) LoadConfig(file string, options interface{}) error
- func (f *FigTree) LoadConfigSource(config *yaml.Node, source string, options interface{}) error
- func (f *FigTree) PopulateEnv(data interface{}) (changeSet map[string]*string)
- func (f *FigTree) ReadFile(file string) (*ConfigSource, error)
- func (f *FigTree) WithApplyChangeSet(apply ChangeSetFunc)
- func (f *FigTree) WithConfigDir(dir string)
- func (f *FigTree) WithCwd(cwd string)
- func (f *FigTree) WithEnvPrefix(env string)
- func (f *FigTree) WithFilterOut(filt FilterOut)
- func (f *FigTree) WithHome(home string)
- func (f *FigTree) WithIgnoreChangeSet()
- func (f *FigTree) WithPreProcessor(pp PreProcessor)
- func (f *FigTree) WithoutExec()
- type FileCoordinate
- type FilterOut
- type Float32Option
- type Float64Option
- type Int16Option
- type Int32Option
- type Int64Option
- type Int8Option
- type IntOption
- type ListBoolOption
- type ListByteOption
- type ListComplex128Option
- type ListComplex64Option
- type ListErrorOption
- type ListFloat32Option
- type ListFloat64Option
- type ListInt16Option
- type ListInt32Option
- type ListInt64Option
- type ListInt8Option
- type ListIntOption
- type ListOption
- func (o ListOption[T]) Append(values ...T) ListOption[T]
- func (o ListOption[T]) IsCumulative() bool
- func (o ListOption[T]) IsDefined() bool
- func (o *ListOption[T]) Set(value string) error
- func (o ListOption[T]) Slice() []T
- func (o ListOption[T]) String() string
- func (o *ListOption[T]) WriteAnswer(name string, value any) error
- type ListRawTypeOption
- type ListRuneOption
- type ListStringOption
- type ListUint16Option
- type ListUint32Option
- type ListUint64Option
- type ListUint8Option
- type ListUintOption
- type ListUintptrOption
- type Logger
- type MapBoolOption
- type MapByteOption
- type MapComplex128Option
- type MapComplex64Option
- type MapErrorOption
- type MapFloat32Option
- type MapFloat64Option
- type MapInt16Option
- type MapInt32Option
- type MapInt64Option
- type MapInt8Option
- type MapIntOption
- type MapOption
- type MapRawTypeOption
- type MapRuneOption
- type MapStringOption
- type MapUint16Option
- type MapUint32Option
- type MapUint64Option
- type MapUint8Option
- type MapUintOption
- type MapUintptrOption
- type MergeOption
- type Merger
- type Option
- func (o *Option[T]) GetSource() SourceLocation
- func (o Option[T]) GetValue() any
- func (o Option[T]) IsBoolFlag() bool
- func (o *Option[T]) IsDefault() bool
- func (o Option[T]) IsDefined() bool
- func (o *Option[T]) IsOverride() bool
- func (o Option[T]) MarshalJSON() ([]byte, error)
- func (o Option[T]) MarshalYAML() (any, error)
- func (o *Option[T]) Set(s string) error
- func (o *Option[T]) SetSource(source SourceLocation)
- func (o *Option[T]) SetValue(v any) error
- func (o Option[T]) String() string
- func (o *Option[T]) UnmarshalJSON(b []byte) error
- func (o *Option[T]) UnmarshalYAML(node *yaml.Node) error
- func (o *Option[T]) WriteAnswer(name string, value any) error
- type PreProcessor
- type RawTypeOption
- type RuneOption
- type SourceLocation
- type SourceOption
- type StringOption
- type Uint16Option
- type Uint32Option
- type Uint64Option
- type Uint8Option
- type UintOption
- type UintptrOption
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultSource will be the value of the `Source` property // for Option[T] when they are constructed via `NewOption[T]`. DefaultSource = NewSource(defaultSource) // OverrideSource will be the value of the `Source` property // for Option[T] when they are populated via kingpin command // line option. OverrideSource = NewSource(overrideSource) )
ideally these would be const if Go supported const structs?
var NewBoolOption = NewOption[bool]
var NewByteOption = NewOption[byte]
var NewComplex128Option = NewOption[complex128]
var NewComplex64Option = NewOption[complex64]
var NewErrorOption = NewOption[error]
var NewFloat32Option = NewOption[float32]
var NewFloat64Option = NewOption[float64]
var NewInt16Option = NewOption[int16]
var NewInt32Option = NewOption[int32]
var NewInt64Option = NewOption[int64]
var NewInt8Option = NewOption[int8]
var NewIntOption = NewOption[int]
var NewRawTypeOption = NewOption[any]
var NewRuneOption = NewOption[rune]
var NewStringOption = NewOption[string]
var NewUint16Option = NewOption[uint16]
var NewUint32Option = NewOption[uint32]
var NewUint64Option = NewOption[uint64]
var NewUint8Option = NewOption[uint8]
var NewUintOption = NewOption[uint]
var NewUintptrOption = NewOption[uintptr]
var StringifyValue = true
StringifyValue is global variable to indicate if the Option should be serialized as just the value (when value is true) or if the entire Option struct should be serialized. This is a hack, and not recommended for general usage, but can be useful for debugging.
Functions ¶
func CanonicalFieldName ¶
func CanonicalFieldName(sf reflect.StructField) string
CanonicalFieldName will return the the field name that will be used with merging maps and structs where the name casing/formatting may not be consistent. If the field uses tag `figtree:",name=MyName"` then that name will be used instead of the default contention.
func FindParentPaths ¶
func MakeMergeStruct ¶
func MakeMergeStruct(structs ...interface{}) interface{}
MakeMergeStruct will take multiple structs and return a pointer to a zero value for the anonymous struct that has all the public fields from all the structs merged into one struct. If there are multiple structs with the same field names, the first appearance of that name will be used.
Types ¶
type BoolOption ¶
type ByteOption ¶
type ChangeSetFunc ¶
type Complex128Option ¶
type Complex128Option = Option[complex128]
type Complex64Option ¶
type ConfigOptions ¶
type ConfigOptions struct {
Overwrite []string `json:"overwrite,omitempty" yaml:"overwrite,omitempty"`
}
type ConfigSource ¶
type ConfigSource struct { Config *yaml.Node Filename string }
type CreateOption ¶
type CreateOption func(*FigTree)
func WithApplyChangeSet ¶
func WithApplyChangeSet(apply ChangeSetFunc) CreateOption
func WithConfigDir ¶
func WithConfigDir(dir string) CreateOption
func WithCwd ¶
func WithCwd(cwd string) CreateOption
func WithEnvPrefix ¶
func WithEnvPrefix(env string) CreateOption
func WithFilterOut ¶
func WithFilterOut(filt FilterOut) CreateOption
func WithHome ¶
func WithHome(home string) CreateOption
func WithPreProcessor ¶
func WithPreProcessor(pp PreProcessor) CreateOption
func WithoutExec ¶
func WithoutExec() CreateOption
type ErrorOption ¶
type FigTree ¶
type FigTree struct {
// contains filtered or unexported fields
}
func NewFigTree ¶
func NewFigTree(opts ...CreateOption) *FigTree
func (*FigTree) FindParentPaths ¶
func (*FigTree) LoadAllConfigSources ¶
func (f *FigTree) LoadAllConfigSources(sources []ConfigSource, options interface{}) error
func (*FigTree) LoadAllConfigs ¶
func (*FigTree) LoadConfig ¶
func (*FigTree) LoadConfigSource ¶
func (*FigTree) PopulateEnv ¶
func (*FigTree) ReadFile ¶
func (f *FigTree) ReadFile(file string) (*ConfigSource, error)
ReadFile will return a ConfigSource for given file path. If the file is executable (and WithoutExec was not used), it will execute the file and return the stdout otherwise it will return the file contents directly.
func (*FigTree) WithApplyChangeSet ¶
func (f *FigTree) WithApplyChangeSet(apply ChangeSetFunc)
func (*FigTree) WithConfigDir ¶
func (*FigTree) WithEnvPrefix ¶
func (*FigTree) WithFilterOut ¶
func (*FigTree) WithIgnoreChangeSet ¶
func (f *FigTree) WithIgnoreChangeSet()
func (*FigTree) WithPreProcessor ¶
func (f *FigTree) WithPreProcessor(pp PreProcessor)
func (*FigTree) WithoutExec ¶
func (f *FigTree) WithoutExec()
type FileCoordinate ¶
FileCoordinate represents the line/column of an option
type Float32Option ¶
type Float64Option ¶
type Int16Option ¶
type Int32Option ¶
type Int64Option ¶
type Int8Option ¶
type ListBoolOption ¶
type ListBoolOption = ListOption[bool]
type ListByteOption ¶
type ListByteOption = ListOption[byte]
type ListComplex128Option ¶
type ListComplex128Option = ListOption[complex128]
type ListComplex64Option ¶
type ListComplex64Option = ListOption[complex64]
type ListErrorOption ¶
type ListErrorOption = ListOption[error]
type ListFloat32Option ¶
type ListFloat32Option = ListOption[float32]
type ListFloat64Option ¶
type ListFloat64Option = ListOption[float64]
type ListInt16Option ¶
type ListInt16Option = ListOption[int16]
type ListInt32Option ¶
type ListInt32Option = ListOption[int32]
type ListInt64Option ¶
type ListInt64Option = ListOption[int64]
type ListInt8Option ¶
type ListInt8Option = ListOption[int8]
type ListIntOption ¶
type ListIntOption = ListOption[int]
type ListOption ¶
func (ListOption[T]) Append ¶
func (o ListOption[T]) Append(values ...T) ListOption[T]
func (ListOption[T]) IsCumulative ¶
func (o ListOption[T]) IsCumulative() bool
IsCumulative implements part of the remainderArg interface as defined by the kingpin command line option library: https://github.com/alecthomas/kingpin/blob/v1.3.4/values.go#L49-L52
func (ListOption[T]) IsDefined ¶
func (o ListOption[T]) IsDefined() bool
func (*ListOption[T]) Set ¶
func (o *ListOption[T]) Set(value string) error
Set implements part of the Value interface as defined by the kingpin command line option library: https://github.com/alecthomas/kingpin/blob/v1.3.4/values.go#L26-L29
func (ListOption[T]) Slice ¶
func (o ListOption[T]) Slice() []T
func (ListOption[T]) String ¶
func (o ListOption[T]) String() string
String implements part of the Value interface as defined by the kingpin command line option library: https://github.com/alecthomas/kingpin/blob/v1.3.4/values.go#L26-L29
func (*ListOption[T]) WriteAnswer ¶
func (o *ListOption[T]) WriteAnswer(name string, value any) error
WriteAnswer implements the Settable interface as defined by the survey prompting library: https://github.com/AlecAivazis/survey/blob/v2.3.5/core/write.go#L15-L18
type ListRawTypeOption ¶
type ListRawTypeOption = ListOption[any]
type ListRuneOption ¶
type ListRuneOption = ListOption[rune]
type ListStringOption ¶
type ListStringOption = ListOption[string]
type ListUint16Option ¶
type ListUint16Option = ListOption[uint16]
type ListUint32Option ¶
type ListUint32Option = ListOption[uint32]
type ListUint64Option ¶
type ListUint64Option = ListOption[uint64]
type ListUint8Option ¶
type ListUint8Option = ListOption[uint8]
type ListUintOption ¶
type ListUintOption = ListOption[uint]
type ListUintptrOption ¶
type ListUintptrOption = ListOption[uintptr]
type Logger ¶
type Logger interface {
Debugf(format string, args ...interface{})
}
var Log Logger = &nullLogger{}
type MapBoolOption ¶
type MapByteOption ¶
type MapComplex128Option ¶
type MapComplex128Option = MapOption[complex128]
type MapComplex64Option ¶
type MapErrorOption ¶
type MapFloat32Option ¶
type MapFloat64Option ¶
type MapInt16Option ¶
type MapInt32Option ¶
type MapInt64Option ¶
type MapInt8Option ¶
type MapIntOption ¶
type MapOption ¶
func (MapOption[T]) IsCumulative ¶
IsCumulative implements part of the remainderArg interface as defined by the kingpin command line option library: https://github.com/alecthomas/kingpin/blob/v1.3.4/values.go#L49-L52
func (*MapOption[T]) Set ¶
Set implements part of the Value interface as defined by the kingpin command line option library: https://github.com/alecthomas/kingpin/blob/v1.3.4/values.go#L26-L29
func (MapOption[T]) String ¶
String implements part of the Value interface as defined by the kingpin command line option library: https://github.com/alecthomas/kingpin/blob/v1.3.4/values.go#L26-L29
func (*MapOption[T]) WriteAnswer ¶
WriteAnswer implements the Settable interface as defined by the survey prompting library: https://github.com/AlecAivazis/survey/blob/v2.3.5/core/write.go#L15-L18
type MapRawTypeOption ¶
type MapRuneOption ¶
type MapStringOption ¶
type MapUint16Option ¶
type MapUint32Option ¶
type MapUint64Option ¶
type MapUint8Option ¶
type MapUintOption ¶
type MapUintptrOption ¶
type MergeOption ¶
type MergeOption func(*Merger)
func PreserveMap ¶
func PreserveMap(keys ...string) MergeOption
func WithSourceFile ¶
func WithSourceFile(source string) MergeOption
type Merger ¶
type Merger struct { Config ConfigOptions `json:"config,omitempty" yaml:"config,omitempty"` // contains filtered or unexported fields }
func NewMerger ¶
func NewMerger(options ...MergeOption) *Merger
func (*Merger) MakeMergeStruct ¶
func (m *Merger) MakeMergeStruct(structs ...interface{}) interface{}
type Option ¶
type Option[T any] struct { Source SourceLocation Defined bool Value T }
func (*Option[T]) GetSource ¶
func (o *Option[T]) GetSource() SourceLocation
func (Option[T]) IsBoolFlag ¶
IsBoolFlag implements part of the boolFlag interface as defined by the kingpin command line option library: https://github.com/alecthomas/kingpin/blob/v1.3.4/values.go#L42-L45
func (*Option[T]) IsOverride ¶
func (Option[T]) MarshalJSON ¶
MarshalJSON implements the Marshaler interface as defined by json: https://cs.opensource.google/go/go/+/refs/tags/go1.18.3:src/encoding/json/encode.go;l=225-227
func (Option[T]) MarshalYAML ¶
MarshalYAML implements the Marshaler interface used by the yaml library: https://github.com/go-yaml/yaml/blob/v3.0.1/yaml.go#L50-L52
func (*Option[T]) Set ¶
Set implements part of the Value interface as defined by the kingpin command line option library: https://github.com/alecthomas/kingpin/blob/v1.3.4/values.go#L26-L29
func (*Option[T]) SetSource ¶
func (o *Option[T]) SetSource(source SourceLocation)
func (*Option[T]) SetValue ¶
SetValue implements the Settings interface as defined by the kingpin command line option library: https://github.com/alecthomas/kingpin/blob/v1.3.4/parsers.go#L13-L15
func (Option[T]) String ¶
String implements part of the Value interface as defined by the kingpin command line option library: https://github.com/alecthomas/kingpin/blob/v1.3.4/values.go#L26-L29
func (*Option[T]) UnmarshalJSON ¶
UnmarshalJSON implements the Unmarshaler interface as defined by json: https://cs.opensource.google/go/go/+/refs/tags/go1.18.3:src/encoding/json/decode.go;l=118-120
func (*Option[T]) UnmarshalYAML ¶
UnmarshalYAML implement the Unmarshaler interface used by the yaml library: https://github.com/go-yaml/yaml/blob/v3.0.1/yaml.go#L36-L38
func (*Option[T]) WriteAnswer ¶
WriteAnswer implements the Settable interface as defined by the survey prompting library: https://github.com/AlecAivazis/survey/blob/v2.3.5/core/write.go#L15-L18
type PreProcessor ¶
type PreProcessor func(*yaml.Node) error
type RawTypeOption ¶
type RuneOption ¶
type SourceLocation ¶
type SourceLocation struct { Name string Location *FileCoordinate }
func NewSource ¶
func NewSource(name string, opts ...SourceOption) SourceLocation
func (SourceLocation) String ¶
func (s SourceLocation) String() string
type SourceOption ¶
type SourceOption func(*SourceLocation) *SourceLocation
func WithLocation ¶
func WithLocation(location *FileCoordinate) SourceOption