Documentation ¶
Index ¶
- Constants
- type Argument
- type ArgumentType
- type Error
- type ErrorType
- type HelpText
- type OptMap
- type Option
- type OptionValue
- func (ov *OptionValue) Bool() (value bool, found bool, err error)
- func (ov *OptionValue) Definition() Option
- func (ov *OptionValue) Float() (value float64, found bool, err error)
- func (ov *OptionValue) Found() bool
- func (ov *OptionValue) Int() (value int, found bool, err error)
- func (ov *OptionValue) String() (value string, found bool, err error)
- func (ov *OptionValue) Uint() (value uint, found bool, err error)
Constants ¶
View Source
const ( Invalid = reflect.Invalid Bool = reflect.Bool Int = reflect.Int Uint = reflect.Uint Float = reflect.Float64 String = reflect.String )
Types of Command options
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Argument ¶
type Argument struct { Name string Type ArgumentType Required bool // error if no value is specified Variadic bool // unlimited values can be specfied SupportsStdin bool // can accept stdin as a value Recursive bool // supports recursive file adding (with '-r' flag) Description string }
func (Argument) EnableRecursive ¶
func (Argument) EnableStdin ¶
type Error ¶
Error is a struct for marshalling errors
func (Error) MarshalJSON ¶ added in v0.3.2
func (*Error) UnmarshalJSON ¶ added in v0.3.2
type HelpText ¶
type HelpText struct { // required Tagline string // used in <cmd usage> ShortDescription string // used in DESCRIPTION SynopsisOptionsValues map[string]string // mappings for synopsis generator // optional - whole section overrides Usage string // overrides USAGE section LongDescription string // overrides DESCRIPTION section Options string // overrides OPTIONS section Arguments string // overrides ARGUMENTS section Subcommands string // overrides SUBCOMMANDS section Synopsis string // overrides SYNOPSIS field }
HelpText is a set of strings used to generate command help text. The help text follows formats similar to man pages, but not exactly the same.
type Option ¶
type Option interface { Name() string // the main name of the option Names() []string // a list of unique names matched with user-provided flags Type() reflect.Kind // value must be this type Description() string // a short string that describes this option WithDefault(interface{}) Option // sets the default value of the option Default() interface{} Parse(str string) (interface{}, error) }
Option is used to specify a field that will be provided by a consumer
func BoolOption ¶
func FloatOption ¶
func StringOption ¶
func UintOption ¶
type OptionValue ¶
func (*OptionValue) Bool ¶
func (ov *OptionValue) Bool() (value bool, found bool, err error)
value accessor methods, gets the value as a certain type
func (*OptionValue) Definition ¶
func (ov *OptionValue) Definition() Option
Definition returns the option definition for the provided value
func (*OptionValue) Found ¶
func (ov *OptionValue) Found() bool
Found returns true if the option value was provided by the user (not a default value)
Click to show internal directories.
Click to hide internal directories.