Documentation
¶
Overview ¶
Package option - internal option struct and methods.
Index ¶
- Variables
- func Sort(list []*Option)
- type Handler
- type Option
- func (opt *Option) CheckRequired() error
- func (opt *Option) Int() int
- func (opt *Option) Save(a ...string) error
- func (opt *Option) SetAlias(alias ...string) *Option
- func (opt *Option) SetBool(b bool) *Option
- func (opt *Option) SetBoolAsOppositeToDefault() *Option
- func (opt *Option) SetCalled(usedAlias string) *Option
- func (opt *Option) SetDefaultStr(s string) *Option
- func (opt *Option) SetDescription(s string) *Option
- func (opt *Option) SetEnvVar(name string) *Option
- func (opt *Option) SetFloat64(f float64) *Option
- func (opt *Option) SetFloat64Slice(s []float64) *Option
- func (opt *Option) SetHelpArgName(s string) *Option
- func (opt *Option) SetInt(i int) *Option
- func (opt *Option) SetIntSlice(s []int) *Option
- func (opt *Option) SetKeyValueToStringMap(k, v string) *Option
- func (opt *Option) SetRequired(msg string) *Option
- func (opt *Option) SetString(s string) *Option
- func (opt *Option) SetStringSlice(s []string) *Option
- func (opt *Option) Synopsis()
- func (opt *Option) ValidateMinMaxArgs() error
- func (opt *Option) Value() interface{}
- type Type
Constants ¶
This section is empty.
Variables ¶
var ErrorMissingRequiredOption = errors.New("")
Logger instance set to `io.Discard` by default. Enable debug logging by setting: `Logger.SetOutput(os.Stderr)`.
Functions ¶
Types ¶
type Option ¶
type Option struct { Name string Aliases []string EnvVar string // Env Var that sets the option value Called bool // Indicates if the option was passed on the command line UsedAlias string // Alias/Env var used when the option was called Handler Handler // method used to handle the option IsOptional bool // Indicates if an option has an optional argument MapKeysToLower bool // Indicates if the option of map type has it keys set ToLower OptType Type // Option Type MinArgs int // minimum args when using multi MaxArgs int // maximum args when using multi IsRequired bool // Indicates if the option is required IsRequiredErr string // Error message for the required option // SuggestedValues used for completions, suggestions don't necessarily limit // the values you are able to use SuggestedValues []string ValidValues []string // ValidValues that can be passed to Save // Help DefaultStr string // String representation of default value Description string // Optional description used for help HelpArgName string // Optional arg name used for help HelpSynopsis string // Help synopsis Unknown bool // Temporary marker used during parsing // Verbatim text used to generate the option // Used in cases where the option is unknown and we eventually have to send it to the remaining slice. Verbatim string // contains filtered or unexported fields }
Option - main object
func (*Option) CheckRequired ¶
CheckRequired - Returns error if the option is required.
func (*Option) Int ¶
Int - Get the option's data. Exposed due to handle increment. Maybe there is a better way.
func (*Option) SetBoolAsOppositeToDefault ¶
func (*Option) SetCalled ¶
SetCalled - Marks the option as called and records the alias used to call it.
func (*Option) SetDefaultStr ¶
SetDefaultStr - Updates the DefaultStr.
func (*Option) SetDescription ¶
SetDescription - Updates the Description.
func (*Option) SetFloat64 ¶
SetFloat64 - Set the option's data.
func (*Option) SetFloat64Slice ¶
SetFloat64Slice - Set the option's data.
func (*Option) SetHelpArgName ¶
SetHelpArgName - Updates the HelpArgName.
func (*Option) SetIntSlice ¶
SetIntSlice - Set the option's data.
func (*Option) SetKeyValueToStringMap ¶
SetKeyValueToStringMap - Set the option's data.
func (*Option) SetRequired ¶
SetRequired - Marks an option as required.
func (*Option) SetStringSlice ¶
SetStringSlice - Set the option's data.
func (*Option) ValidateMinMaxArgs ¶
ValidateMinMaxArgs - validates that the min and max make sense.
NOTE: This should only be called to validate Repeat types.