Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrFailedToLoadToml = errors.New("Failed to load toml.") ErrFailedToLoadJson = errors.New("Failed to load json.") ErrConfigValueNotSet = errors.New("Config variable is not set.") )
View Source
var ParsingTypeStringMap = map[ParsingType]string{ EnvironmentVariables: "Environment", JsonConfig: "JSON Config", TomlConfig: "Toml Config", CliFlags: "CLI Flag", DefaultValue: "Default Value", }
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// Used to name the App in the help text.
Name string
// The "Usage" section in the help text.
Usage string
// The text used for the copyright section in the help text.
Copyright string
// The order in which variable sources will be parsed, values later in the array will be parsed afterwards, overwriting earlier sources.
// Default order is: CLI Flag > Toml Config > JSON Config > Environment
ParsingOrder []ParsingType
// Main command attached to the app.
Command *Command
// List of authors used in the help text.
Authors []Author
// The keys in this map are used to check for help values, defaults are "help", "-h", and "--help"
HelpCommands map[string]bool
// If help text variables will be displayed in a table. Defaults to true.
HelpTextVariablesInTable bool
// If overridden variables will be displayed in a table. Defaults to false.
OverridesOutputInTable bool
// All output will not include color
RemoveColor bool
// Turn off all output
Silent bool
// contains filtered or unexported fields
}
func (*App) PrintHelpCommand ¶
func (*App) PrintMissingRequiredVariables ¶
func (a *App) PrintMissingRequiredVariables()
type BoolVariable ¶
type BoolVariable struct {
Name string
Description string
Required bool
Default bool
Destination *bool
// contains filtered or unexported fields
}
func (*BoolVariable) GetDefault ¶
func (b *BoolVariable) GetDefault() (interface{}, bool)
func (*BoolVariable) GetDescription ¶
func (b *BoolVariable) GetDescription() string
func (*BoolVariable) GetDestination ¶
func (b *BoolVariable) GetDestination() interface{}
func (*BoolVariable) GetName ¶
func (b *BoolVariable) GetName() string
func (*BoolVariable) IsRequired ¶
func (b *BoolVariable) IsRequired() bool
type Command ¶
type Command struct {
Name string
Usage string
LongDescription string
BeforeFunc func(c *Command) error
Subcommands []*Command
Variables []Variable
Action func()
Active bool
// contains filtered or unexported fields
}
func (*Command) GetActiveCommands ¶
Get the set of active commands. All commands in the chain of arguments are considered active.
func (*Command) GetExpandedActiveCommmands ¶
Helper to get a map of expanded names to the actual command.
func (*Command) GetExpandedName ¶
Get the expanded name of a command, which includes the name of the parent commands, separated by a "." ex. main.sub1.sub2
func (*Command) GetVariableMap ¶
Helper to get a map of variables by variable name.
type ConfigVariable ¶
type ConfigVariable struct {
*StringVariable
Type ParsingType
// contains filtered or unexported fields
}
func (*ConfigVariable) ParseConfig ¶
func (c *ConfigVariable) ParseConfig(set *flag.FlagSet) error
type DurationVariable ¶ added in v1.1.0
type DurationVariable struct {
Name string
Description string
Default time.Duration
Required bool
Destination *time.Duration
// contains filtered or unexported fields
}
func (*DurationVariable) GetDefault ¶ added in v1.1.0
func (d *DurationVariable) GetDefault() (interface{}, bool)
func (*DurationVariable) GetDescription ¶ added in v1.1.0
func (d *DurationVariable) GetDescription() string
func (*DurationVariable) GetDestination ¶ added in v1.1.0
func (d *DurationVariable) GetDestination() interface{}
func (*DurationVariable) GetName ¶ added in v1.1.0
func (d *DurationVariable) GetName() string
func (*DurationVariable) IsRequired ¶ added in v1.1.0
func (d *DurationVariable) IsRequired() bool
type Float64Variable ¶
type Float64Variable struct {
Name string
Description string
Default float64
Required bool
Destination *float64
// contains filtered or unexported fields
}
func (*Float64Variable) GetDefault ¶
func (f *Float64Variable) GetDefault() (interface{}, bool)
func (*Float64Variable) GetDescription ¶
func (f *Float64Variable) GetDescription() string
func (*Float64Variable) GetDestination ¶
func (f *Float64Variable) GetDestination() interface{}
func (*Float64Variable) GetName ¶
func (f *Float64Variable) GetName() string
func (*Float64Variable) IsRequired ¶
func (f *Float64Variable) IsRequired() bool
type Int64Variable ¶
type Int64Variable struct {
Name string
Description string
Default int64
Required bool
Destination *int64
// contains filtered or unexported fields
}
func (*Int64Variable) GetDefault ¶
func (i *Int64Variable) GetDefault() (interface{}, bool)
func (*Int64Variable) GetDescription ¶
func (i *Int64Variable) GetDescription() string
func (*Int64Variable) GetDestination ¶
func (i *Int64Variable) GetDestination() interface{}
func (*Int64Variable) GetName ¶
func (i *Int64Variable) GetName() string
func (*Int64Variable) IsRequired ¶
func (i *Int64Variable) IsRequired() bool
type IntVariable ¶
type IntVariable struct {
Name string
Description string
Default int
Required bool
Destination *int
// contains filtered or unexported fields
}
func (*IntVariable) GetDefault ¶
func (i *IntVariable) GetDefault() (interface{}, bool)
func (*IntVariable) GetDescription ¶
func (i *IntVariable) GetDescription() string
func (*IntVariable) GetDestination ¶
func (i *IntVariable) GetDestination() interface{}
func (*IntVariable) GetName ¶
func (i *IntVariable) GetName() string
func (*IntVariable) IsRequired ¶
func (i *IntVariable) IsRequired() bool
type ParsingType ¶
type ParsingType int
const ( EnvironmentVariables ParsingType = iota JsonConfig TomlConfig CliFlags DefaultValue )
type StringVariable ¶
type StringVariable struct {
Name string
Description string
Default string
Required bool
Destination *string
// contains filtered or unexported fields
}
func (*StringVariable) GetDefault ¶
func (s *StringVariable) GetDefault() (interface{}, bool)
func (*StringVariable) GetDescription ¶
func (s *StringVariable) GetDescription() string
func (*StringVariable) GetDestination ¶
func (s *StringVariable) GetDestination() interface{}
func (*StringVariable) GetName ¶
func (s *StringVariable) GetName() string
func (*StringVariable) IsRequired ¶
func (s *StringVariable) IsRequired() bool
type Variable ¶
type Variable interface {
// Get the Name
GetName() string
// Get the Description
GetDescription() string
// Get the Destination pointer
GetDestination() interface{}
// return the default value, bool if it's set or not.
GetDefault() (interface{}, bool)
// Get if it's a required variable or not
IsRequired() bool
// contains filtered or unexported methods
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
basic
command
|
|
|
duration_variable
command
|
|
|
overwritten_pointer
command
|
Click to show internal directories.
Click to hide internal directories.




