Documentation
¶
Index ¶
- Constants
- func Unmarshaler(dec *strdecode.Decoder) func(dst reflect.Value, typ reflect.Type, src []string) error
- type Flag
- type FlagSet
- func (set *FlagSet) Bool(short, long string, value bool, usage string, required bool) *bool
- func (set *FlagSet) BoolVar(ptr *bool, short, long string, value bool, usage string, required bool)
- func (set *FlagSet) Bytes(short, long string, value []byte, usage string, required bool) *[]byte
- func (set *FlagSet) BytesVar(ptr *[]byte, short, long string, value []byte, usage string, required bool)
- func (set *FlagSet) Float(short, long string, value float64, usage string, required bool) *float64
- func (set *FlagSet) FloatVar(ptr *float64, short, long string, value float64, usage string, required bool)
- func (set *FlagSet) Int(short, long string, value int, usage string, required bool) *int
- func (set *FlagSet) Int64(short, long string, value int64, usage string, required bool) *int64
- func (set *FlagSet) Int64Var(ptr *int64, short, long string, value int64, usage string, required bool)
- func (set *FlagSet) IntVar(ptr *int, short, long string, value int, usage string, required bool)
- func (set *FlagSet) Parse(args []string) (unknown []string, err error)
- func (set *FlagSet) ParseStrict(args []string) error
- func (set *FlagSet) String(short, long string, value string, usage string, required bool) *string
- func (set *FlagSet) StringVar(ptr *string, short, long string, value string, usage string, required bool)
- func (set *FlagSet) StructFields(dst interface{})
- func (set *FlagSet) Uint(short, long string, value uint, usage string, required bool) *uint
- func (set *FlagSet) Uint64(short, long string, value uint64, usage string, required bool) *uint64
- func (set *FlagSet) Uint64Var(ptr *uint64, short, long string, value uint64, usage string, required bool)
- func (set *FlagSet) UintVar(ptr *uint, short, long string, value uint, usage string, required bool)
- func (set *FlagSet) Validate() error
- func (set *FlagSet) Var(dst interface{}, short, long, value, usage string, required bool)
- type Flags
- type InvalidFlagError
Constants ¶
View Source
const ( // Short flag name struct tag. ShortNameTag = "short" // Long flag name struct tag. LongNameTag = "long" // Usage flag struct tag. UsageTag = "usage" // Required flag struct tag. RequiredTag = "required" // Default value struct tag. DefaultTag = "default" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Flag ¶
type Flag struct { // Short is the short-form flag name, parsed from CLI flags prefixed by '-'. Short string // Long is the long-form flag name, parsed from CLI flags prefixed by '--'. Long string // Usage is the description for this CLI flag, used when generating usage string. Usage string // Required specifies whether this flag is required, if so returning error. Required bool // Default is the default value for this CLI flag, used when no value provided. Default string // Values contains raw value strings populated during parse stage. Values []string // contains filtered or unexported fields }
func (Flag) AppendUsage ¶
AppendUsage will append (new-line terminated) usage information for flag to b.
type FlagSet ¶
type FlagSet struct { // Flags should contain possible flags to be searched for when parsing CLI args. Flags Flags // Unmarshal should unmarshal possible CLI argument value slice into 'dst'. Note // that for singular values len = 1, if flag was provided with no value len = 0. Unmarshal func(dst reflect.Value, typ reflect.Type, src []string) error }
func (*FlagSet) Parse ¶
Parse ... will parse value strings from CLI arguments slice, storing in the Decoder before call to Decode(). Returns unrecognized arguments.
func (*FlagSet) ParseStrict ¶
ParseStrict will perform .Parse() but return error in the case that unknown arguments are returned.
func (*FlagSet) StructFields ¶
func (set *FlagSet) StructFields(dst interface{})
type Flags ¶
type Flags []Flag
Flags provides helpful methods for a slice of flags.
func (Flags) AppendUsage ¶
AppendUsage will call .AppendUsage() for each contained Flag and return accumulated bytes.
type InvalidFlagError ¶
InvalidFlagError encapsulates error information regarding an invalid flag when calling cli.Flags{}.Validate().
func (*InvalidFlagError) Error ¶
func (err *InvalidFlagError) Error() string
Click to show internal directories.
Click to hide internal directories.