Documentation ¶
Index ¶
- Variables
- func GetBoolFlags(config interface{}) ([]string, error)
- func GetFlags(config interface{}) ([]string, error)
- func Load(config interface{}, defaultValue interface{}, args []string) error
- func LoadWithCommand(cmd *Command, cmdArgs []string, customParsers map[reflect.Type]Parser, ...) error
- func LoadWithParsers(config interface{}, defaultValue interface{}, args []string, ...) error
- func PrintError(err error, flagmap map[string]reflect.StructField, ...) error
- func PrintErrorWithCommand(err error, flagmap map[string]reflect.StructField, ...) error
- func PrintHelp(flagmap map[string]reflect.StructField, defaultValmap map[string]reflect.Value, ...) error
- func PrintHelpWithCommand(flagmap map[string]reflect.StructField, defaultValmap map[string]reflect.Value, ...) error
- type Command
- type Duration
- type Flaeg
- type Parser
- type SliceStrings
Constants ¶
This section is empty.
Variables ¶
var ErrParserNotFound = errors.New("Parser not found or custom parser missing")
ErrParserNotFound is thrown when a field is flaged but not parser match its type
Functions ¶
func GetBoolFlags ¶
GetPointerFlags returns flags on pointers
func Load ¶
Load initializes config : struct fields given by reference, with args : arguments. Some custom parsers may be given.
func LoadWithCommand ¶
func LoadWithCommand(cmd *Command, cmdArgs []string, customParsers map[reflect.Type]Parser, subCommand []*Command) error
LoadWithCommand initializes config : struct fields given by reference, with args : arguments. Some custom parsers and some subCommand may be given.
func LoadWithParsers ¶
func LoadWithParsers(config interface{}, defaultValue interface{}, args []string, customParsers map[reflect.Type]Parser) error
LoadWithParsers initializes config : struct fields given by reference, with args : arguments. Some custom parsers may be given.
func PrintError ¶
func PrintError(err error, flagmap map[string]reflect.StructField, defaultValmap map[string]reflect.Value, parsers map[reflect.Type]Parser) error
PrintError takes a not nil error and prints command line help
func PrintErrorWithCommand ¶
func PrintErrorWithCommand(err error, flagmap map[string]reflect.StructField, defaultValmap map[string]reflect.Value, parsers map[reflect.Type]Parser, cmd *Command, subCmd []*Command) error
PrintErrorWithCommand takes a not nil error and prints command line help
Types ¶
type Command ¶
type Command struct { Name string Description string Config interface{} DefaultPointersConfig interface{} //TODO:case DefaultPointersConfig is nil Run func() error Metadata map[string]string }
Command structure contains program/command information (command name and description) Config must be a pointer on the configuration struct to parse (it contains default values of field) DefaultPointersConfig contains default pointers values: those values are set on pointers fields if their flags are called It must be the same type(struct) as Config Run is the func which launch the program using initialized configuration structure
type Duration ¶ added in v1.0.0
Duration is a custom type suitable for parsing duration values. It supports `time.ParseDuration`-compatible values and suffix-less digits; in the latter case, seconds are assumed.
func (*Duration) Get ¶ added in v1.0.0
func (d *Duration) Get() interface{}
Get returns the duration value.
func (*Duration) SetValue ¶ added in v1.0.0
func (d *Duration) SetValue(val interface{})
SetValue sets the duration from the given Duration-asserted value.
func (*Duration) String ¶ added in v1.0.0
String returns a string representation of the duration value.
func (*Duration) UnmarshalText ¶ added in v1.0.0
UnmarshalText deserializes the given text into a duration value. It is meant to support TOML decoding of durations.
type Flaeg ¶
type Flaeg struct {
// contains filtered or unexported fields
}
Flaeg struct contains commands (at least the root one) and row arguments (command and/or flags) a map of custom parsers could be use
func (*Flaeg) AddCommand ¶
AddCommand adds sub-command to the root command
func (*Flaeg) GetCommand ¶
GetCommand splits args and returns the called command (by reference) It returns nil and a not nil error if it fails
type SliceStrings ¶
type SliceStrings []string
SliceStrings parse slice of strings
func (*SliceStrings) Set ¶
func (s *SliceStrings) Set(str string) error
Set adds strings elem into the the parser it splits str on , and ;
func (*SliceStrings) SetValue ¶
func (s *SliceStrings) SetValue(val interface{})
SetValue sets []string into the parser
func (*SliceStrings) String ¶
func (s *SliceStrings) String() string
String return slice in a string