Documentation
¶
Index ¶
- Variables
- func GetConfigFilePath() (string, error)
- func ToString(slice []string) string
- type FlagData
- type FlagSet
- func (flagSet *FlagSet) BoolVar(field *bool, long string, defaultValue bool, usage string) *FlagData
- func (flagSet *FlagSet) BoolVarP(field *bool, long, short string, defaultValue bool, usage string) *FlagData
- func (flagSet *FlagSet) CreateGroup(groupName, description string, flags ...*FlagData)
- func (flagSet *FlagSet) DurationVar(field *time.Duration, long string, defaultValue time.Duration, usage string) *FlagData
- func (flagSet *FlagSet) DurationVarP(field *time.Duration, long, short string, defaultValue time.Duration, ...) *FlagData
- func (flagSet *FlagSet) IntVar(field *int, long string, defaultValue int, usage string) *FlagData
- func (flagSet *FlagSet) IntVarP(field *int, long, short string, defaultValue int, usage string) *FlagData
- func (flagSet *FlagSet) MergeConfigFile(file string) error
- func (flagSet *FlagSet) Parse() error
- func (flagSet *FlagSet) RuntimeMapVar(field *RuntimeMap, long string, defaultValue []string, usage string) *FlagData
- func (flagSet *FlagSet) RuntimeMapVarP(field *RuntimeMap, long, short string, defaultValue []string, usage string) *FlagData
- func (flagSet *FlagSet) SetDescription(description string)
- func (flagSet *FlagSet) SetGroup(name, description string)
- func (flagSet *FlagSet) StringSliceVar(field *StringSlice, long string, defaultValue []string, usage string, ...) *FlagData
- func (flagSet *FlagSet) StringSliceVarConfigOnly(field *StringSlice, long string, defaultValue []string, usage string) *FlagData
- func (flagSet *FlagSet) StringSliceVarP(field *StringSlice, long, short string, defaultValue StringSlice, usage string, ...) *FlagData
- func (flagSet *FlagSet) StringVar(field *string, long, defaultValue, usage string) *FlagData
- func (flagSet *FlagSet) StringVarEnv(field *string, long, short, defaultValue, envName, usage string) *FlagData
- func (flagSet *FlagSet) StringVarP(field *string, long, short, defaultValue, usage string) *FlagData
- func (flagSet *FlagSet) Var(field flag.Value, long, usage string) *FlagData
- func (flagSet *FlagSet) VarP(field flag.Value, long, short, usage string) *FlagData
- type InsertionOrderedMap
- type Options
- type RuntimeMap
- type StringSlice
Constants ¶
This section is empty.
Variables ¶
var CommaSeparatedStringSliceOptions = Options{
IsEmpty: isEmpty,
}
CommaSeparatedStringSliceOptions represents a list of comma separated items Tokenization: Comma Normalization: None Type: []string Example: -flag value1,value2 => {"value1", "value2"}
var FileCommaSeparatedStringSliceOptions = Options{ IsEmpty: isEmpty, IsFromFile: func(s string) bool { return true }, }
FileCommaSeparatedStringSliceOptions represents a list of comma separated files containing items Tokenization: Comma Normalization: None Type: []string Example: -flag test.txt # with test.txt containing on multiple lines value1 and nvalue2 => {"value1", "value2"}
var FileNormalizedStringSliceOptions = Options{ IsEmpty: isEmpty, Normalize: normalizeLowercase, IsFromFile: func(s string) bool { return true }, }
FileNormalizedStringSliceOptions represents a list of path items Tokenization: Comma Normalization: Standard Type: []string Example: -flag /value/1 -flag value2 => {"/value/1", "value2"}
var FileStringSliceOptions = Options{ IsEmpty: isEmpty, Normalize: normalizeTrailingParts, IsFromFile: func(s string) bool { return true }, }
FileStringSliceOptions represents a list of items stored in a file Tokenization: Standard Normalization: Standard
var NormalizedOriginalStringSliceOptions = Options{
IsEmpty: isEmpty,
Normalize: normalize,
}
NormalizedOriginalStringSliceOptions represents a list of items Tokenization: None Normalization: Standard Type: []string Example: -flag /value/1 -flag value2 => {"/value/1", "value2"}
var NormalizedStringSliceOptions = Options{
IsEmpty: isEmpty,
Normalize: normalizeLowercase,
}
NormalizedStringSliceOptions represents a list of items Tokenization: Comma Normalization: Standard
var StringSliceOptions = Options{}
StringSliceOptions represents the default string slice (list of items) Tokenization: None Normalization: None Type: []string Example: -flag value1 -flag value2 => {"value1", "value2"}
Functions ¶
func GetConfigFilePath ¶ added in v0.0.8
GetConfigFilePath returns the default config file path
Types ¶
type FlagData ¶ added in v0.0.5
type FlagData struct {
// contains filtered or unexported fields
}
type FlagSet ¶
type FlagSet struct {
Marshal bool
CommandLine *flag.FlagSet
// OtherOptionsGroupName is the name for all flags not in a group
OtherOptionsGroupName string
// contains filtered or unexported fields
}
FlagSet is a list of flags for an application
func NewFlagSet ¶ added in v0.0.5
func NewFlagSet() *FlagSet
NewFlagSet creates a new flagSet structure for the application
func (*FlagSet) BoolVar ¶
func (flagSet *FlagSet) BoolVar(field *bool, long string, defaultValue bool, usage string) *FlagData
BoolVar adds a bool flag with a longname
func (*FlagSet) BoolVarP ¶
func (flagSet *FlagSet) BoolVarP(field *bool, long, short string, defaultValue bool, usage string) *FlagData
BoolVarP adds a bool flag with a shortname and longname
func (*FlagSet) CreateGroup ¶ added in v0.0.8
CreateGroup within the flagset
func (*FlagSet) DurationVar ¶ added in v0.0.8
func (flagSet *FlagSet) DurationVar(field *time.Duration, long string, defaultValue time.Duration, usage string) *FlagData
DurationVar adds a duration flag with a longname
func (*FlagSet) DurationVarP ¶ added in v0.0.8
func (flagSet *FlagSet) DurationVarP(field *time.Duration, long, short string, defaultValue time.Duration, usage string) *FlagData
DurationVarP adds a duration flag with a shortname and longname
func (*FlagSet) IntVarP ¶
func (flagSet *FlagSet) IntVarP(field *int, long, short string, defaultValue int, usage string) *FlagData
IntVarP adds a int flag with a shortname and longname
func (*FlagSet) MergeConfigFile ¶
MergeConfigFile reads a config file to merge values from.
func (*FlagSet) RuntimeMapVar ¶ added in v0.0.7
func (flagSet *FlagSet) RuntimeMapVar(field *RuntimeMap, long string, defaultValue []string, usage string) *FlagData
RuntimeMapVarP adds a runtime only map flag with a longname
func (*FlagSet) RuntimeMapVarP ¶ added in v0.0.7
func (flagSet *FlagSet) RuntimeMapVarP(field *RuntimeMap, long, short string, defaultValue []string, usage string) *FlagData
RuntimeMapVarP adds a runtime only map flag with a shortname and longname
func (*FlagSet) SetDescription ¶
SetDescription sets the description field for a flagSet to a value.
func (*FlagSet) SetGroup ¶ added in v0.0.5
SetGroup sets a group with name and description for the command line options
The order in which groups are passed is also kept as is, similar to flags.
func (*FlagSet) StringSliceVar ¶
func (flagSet *FlagSet) StringSliceVar(field *StringSlice, long string, defaultValue []string, usage string, options Options) *FlagData
StringSliceVar adds a string slice flag with a longname Supports ONE value at a time. Adding multiple values require repeating the argument (-flag value1 -flag value2) No value normalization is happening.
func (*FlagSet) StringSliceVarConfigOnly ¶ added in v0.0.8
func (flagSet *FlagSet) StringSliceVarConfigOnly(field *StringSlice, long string, defaultValue []string, usage string) *FlagData
StringSliceVarConfigOnly adds a string slice config value (without flag) with a longname
func (*FlagSet) StringSliceVarP ¶
func (flagSet *FlagSet) StringSliceVarP(field *StringSlice, long, short string, defaultValue StringSlice, usage string, options Options) *FlagData
StringSliceVarP adds a string slice flag with a shortname and longname Use options to customize the behavior
func (*FlagSet) StringVarEnv ¶ added in v0.0.3
func (flagSet *FlagSet) StringVarEnv(field *string, long, short, defaultValue, envName, usage string) *FlagData
StringVarEnv adds a string flag with a shortname and longname with a default value read from env variable with a default value fallback
func (*FlagSet) StringVarP ¶
func (flagSet *FlagSet) StringVarP(field *string, long, short, defaultValue, usage string) *FlagData
StringVarP adds a string flag with a shortname and longname
type InsertionOrderedMap ¶ added in v0.0.5
type InsertionOrderedMap struct {
// contains filtered or unexported fields
}
func (*InsertionOrderedMap) Set ¶ added in v0.0.5
func (insertionOrderedMap *InsertionOrderedMap) Set(key string, value *FlagData)
type RuntimeMap ¶ added in v0.0.7
type RuntimeMap struct {
// contains filtered or unexported fields
}
RuntimeMap is a runtime only map of interfaces
func (*RuntimeMap) AsMap ¶ added in v0.0.7
func (runtimeMap *RuntimeMap) AsMap() map[string]interface{}
AsMap returns the internal map as reference - changes are allowed
func (*RuntimeMap) Del ¶ added in v0.0.8
func (runtimeMap *RuntimeMap) Del(key string) error
Del removes the specified key
func (*RuntimeMap) IsEmpty ¶ added in v0.0.7
func (runtimeMap *RuntimeMap) IsEmpty() bool
IsEmpty specifies if the underlying map is empty
func (*RuntimeMap) Set ¶ added in v0.0.7
func (runtimeMap *RuntimeMap) Set(value string) error
Set inserts a value to the map. Format: key=value
func (RuntimeMap) String ¶ added in v0.0.7
func (runtimeMap RuntimeMap) String() string
type StringSlice ¶
type StringSlice []string
StringSlice is a slice of strings
func (*StringSlice) Set ¶
func (stringSlice *StringSlice) Set(value string) error
Set appends a value to the string slice.
func (StringSlice) String ¶
func (stringSlice StringSlice) String() string