Documentation ¶
Index ¶
- func EnsureDir(fileName string)
- func FileExists(filePath string) bool
- func Join(path, filename string) string
- func MinUint32(a, b uint32) uint32
- type App
- func (a *App) AddCommands(c ...cli.Command)
- func (a *App) AddDefaults(d []cli.Flag, c []ConfByCategories)
- func (a *App) AddFlags(f ...cli.Flag)
- func (a *App) AddHook(group, name string, fn HookFunc)
- func (a *App) AddToAfter(before bool, fn func(c *cli.Context) (err error))
- func (a *App) Bool(group, name, usage, envVar string, sanitizer ...HookFunc) *cli.BoolFlag
- func (a *App) BoolTrue(group, name, usage, envVar string, sanitizer ...HookFunc) *cli.BoolTFlag
- func (a *App) Duration(group, name, usage string, value time.Duration, envVar string, ...) *cli.DurationFlag
- func (a *App) FlagExists(group, name string) (ok bool)
- func (a *App) Float64(group, name, usage string, value float64, envVar string, sanitizer ...HookFunc) *cli.Float64Flag
- func (a *App) GetBool(group, name string) (o bool, err error)
- func (a *App) GetConf(group, name string) (o interface{}, err error)
- func (a *App) GetDuration(group, name string) (o time.Duration, err error)
- func (a *App) GetFloat64(group, name string) (o float64, err error)
- func (a *App) GetInt(group, name string) (o int, err error)
- func (a *App) GetString(group, name string) (o string, err error)
- func (a *App) GetStringSlice(group, name string) (o cli.StringSlice, err error)
- func (a *App) GetUint(group, name string) (o uint, err error)
- func (a *App) GroupExists(group string) (ok bool)
- func (a *App) Initialize()
- func (a *App) Int(group, name, usage string, value int, envVar string, sanitizer ...HookFunc) *cli.IntFlag
- func (a *App) LoadConf() (err error)
- func (a *App) NewCommand(name string, usage string, action interface{}, subcommands cli.Commands, ...) cli.Command
- func (a *App) RemoveHook(group, name string, fn HookFunc)
- func (a *App) SaveConf()
- func (a *App) SetBool(group, name string, value bool) (err error)
- func (a *App) SetCommands(c ...cli.Command)
- func (a *App) SetConf(group, name string, value interface{}) (err error)
- func (a *App) SetDefaults(d []cli.Flag, c []ConfByCategories)
- func (a *App) SetDuration(group, name string, value time.Duration) (err error)
- func (a *App) SetFlags(f ...cli.Flag)
- func (a *App) SetFloat64(group, name string, value float64) (err error)
- func (a *App) SetInt(group, name string, value int) (err error)
- func (a *App) SetString(group, name, value string) (err error)
- func (a *App) SetStringSlice(group, name string, value []string) (err error)
- func (a *App) SetUint(group, name string, value uint) (err error)
- func (a *App) String(group, name, usage, value, envVar string, sanitizer ...HookFunc) *cli.StringFlag
- func (a *App) StringSlice(group, name, usage string, val []string, envVar string, sanitizer ...HookFunc) *cli.StringSliceFlag
- func (a *App) SubCommands(sc ...cli.Command) []cli.Command
- func (a *App) Uint(group, name, usage string, value uint, envVar string, sanitizer ...HookFunc) *cli.UintFlag
- type ConfByCategories
- type ConfCategory
- type HookFunc
- func CheckPath() HookFunc
- func CheckURL() HookFunc
- func DurationBounds(min, max time.Duration) HookFunc
- func Example() HookFunc
- func Float64Bounds(min, max float64) HookFunc
- func IntBounds(min, max int) HookFunc
- func ToHookFunc(fn func(interface{}) error) HookFunc
- func UintBounds(min, max uint) HookFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureDir ¶
func EnsureDir(fileName string)
EnsureDir checks a file could be written to a path, creates the directories as needed
func FileExists ¶
FileExists reports whether the named file or directory exists.
Types ¶
type App ¶
func NewApp ¶
func NewApp(name, version, description, copyright string, action, before, after func(c *cli.Context) (err error), ) (a *App)
NewApp returns a new App note that this by default includes a datadir for saving the flags defined for the app and a version subcommand (in addition to the flags)
func (*App) AddCommands ¶
AddCommands appends a slice of cli.Command into an App's commands
func (*App) AddDefaults ¶
func (a *App) AddDefaults(d []cli.Flag, c []ConfByCategories)
AddDefaults appends a set of flags and preset configurations to the existing this is usually what the consuming app will use This should be run after Initialize
func (*App) Duration ¶
func (a *App) Duration(group, name, usage string, value time.Duration, envVar string, sanitizer ...HookFunc) *cli.DurationFlag
Duration returns an cli.DurationFlag
func (*App) FlagExists ¶
FlagExists returns true if the configuration item exists
func (*App) Float64 ¶
func (a *App) Float64(group, name, usage string, value float64, envVar string, sanitizer ...HookFunc) *cli.Float64Flag
Float64 returns an cli.Float64Flag
func (*App) GetDuration ¶
GetDuration returns the pointer to the time.Duration of the config item Value
func (*App) GetFloat64 ¶
GetFloat64 returns the pointer to the float64 of the config item Value
func (*App) GetStringSlice ¶
func (a *App) GetStringSlice(group, name string) (o cli.StringSlice, err error)
GetStringSlice returns the pointer to the string slice of the config item Value
func (*App) GroupExists ¶
GroupExists returns true if the configuration group exists
func (*App) Initialize ¶
func (a *App) Initialize()
Initialize values that can only be generated after the generators run
func (*App) Int ¶
func (a *App) Int(group, name, usage string, value int, envVar string, sanitizer ...HookFunc) *cli.IntFlag
Int returns an cli.IntFlag
func (*App) LoadConf ¶
LoadConf reads the configuration located in the datadir folder into the app config database
func (*App) NewCommand ¶
func (a *App) NewCommand(name string, usage string, action interface{}, subcommands cli.Commands, flags []cli.Flag, aliases ...string) cli.Command
NewCommand returns a cli.Command
func (*App) RemoveHook ¶
RemoveHook removes a change hook from a flag
func (*App) SaveConf ¶
func (a *App) SaveConf()
SaveConf writes the configuration data to disk in json format
func (*App) SetCommands ¶
SetCommands places a slice of cli.Command into an App
func (*App) SetDefaults ¶
func (a *App) SetDefaults(d []cli.Flag, c []ConfByCategories)
SetDefaults loads a set of flag and configured structures into the app this is used to completely reset the defaults This should be run after Initialize
func (*App) SetDuration ¶
SetDuration sets the Value stored in the config item
func (*App) SetFloat64 ¶
SetFloat64 sets the Value stored in the config item
func (*App) SetStringSlice ¶
SetStringSlice sets the Value stored in the config item
func (*App) String ¶
func (a *App) String(group, name, usage, value, envVar string, sanitizer ...HookFunc) *cli.StringFlag
String returns an cli.StringFlag
func (*App) StringSlice ¶
func (a *App) StringSlice(group, name, usage string, val []string, envVar string, sanitizer ...HookFunc) *cli.StringSliceFlag
StringSlice returns and cli.StringSliceFlag
func (*App) SubCommands ¶
SubCommands returns a slice of cli.Command
type ConfByCategories ¶
type ConfByCategories map[string]ConfCategory
type ConfCategory ¶
type ConfCategory map[string]confItem
type HookFunc ¶
type HookFunc *func(interface{}) error
func CheckPath ¶
func CheckPath() HookFunc
CheckPath cleans the filesystem path of special characters
func DurationBounds ¶
DurationBounds allows setting a floor and ceiling on a value
func Example ¶
func Example() HookFunc
Example is a dummy that returns always no error, use as a prototype
func Float64Bounds ¶
Float64Bounds allows setting a floor and ceiling on a value
func ToHookFunc ¶
func UintBounds ¶
UintBounds allows setting a floor and ceiling on a value