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) SetBoolDefault(b bool) *Option
- func (opt *Option) SetBoolPtr(b *bool) *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) SetFloat64Ptr(f *float64) *Option
- func (opt *Option) SetHelpArgName(s string) *Option
- func (opt *Option) SetInt(i int) *Option
- func (opt *Option) SetIntPtr(i *int) *Option
- func (opt *Option) SetIntSlice(s []int) *Option
- func (opt *Option) SetIntSlicePtr(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) SetStringMapPtr(m *map[string]string) *Option
- func (opt *Option) SetStringPtr(s *string) *Option
- func (opt *Option) SetStringSlice(s []string) *Option
- func (opt *Option) SetStringSlicePtr(s *[]string) *Option
- func (opt *Option) Value() interface{}
- type Type
Constants ¶
This section is empty.
Variables ¶
Debug Logger instance set to `ioutil.Discard` by default. Enable debug logging by setting: `Debug.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 // 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 // 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) SetBoolDefault ¶ added in v0.22.0
func (*Option) SetBoolPtr ¶
SetBoolPtr - Set the option's data.
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) SetEnvVar ¶ added in v0.19.0
SetEnvVar - Sets the name of the Env var that sets the option's value.
func (*Option) SetFloat64 ¶
SetFloat64 - Set the option's data.
func (*Option) SetFloat64Ptr ¶
SetFloat64Ptr - Set the option's data.
func (*Option) SetHelpArgName ¶
SetHelpArgName - Updates the HelpArgName.
func (*Option) SetIntSlice ¶
SetIntSlice - Set the option's data.
func (*Option) SetIntSlicePtr ¶
SetIntSlicePtr - 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) SetStringMapPtr ¶
SetStringMapPtr - Set the option's data.
func (*Option) SetStringPtr ¶
SetStringPtr - Set the option's data.
func (*Option) SetStringSlice ¶
SetStringSlice - Set the option's data.
func (*Option) SetStringSlicePtr ¶
SetStringSlicePtr - Set the option's data.