Documentation
¶
Overview ¶
Package flagset provides functions for handling command line arguments
Index ¶
- type Arg
- type Command
- type Flag
- func (f *Flag) Command() string
- func (f *Flag) Delimiter() string
- func (f *Flag) Description() string
- func (f *Flag) Env() string
- func (f *Flag) FieldIndex() []int
- func (f *Flag) FormattedArg() string
- func (f *Flag) Global() bool
- func (f *Flag) ID() int
- func (f *Flag) Kind() string
- func (f *Flag) Long() string
- func (f *Flag) Name() string
- func (f *Flag) ParentID() int
- func (f *Flag) ParentIndex() []int
- func (f *Flag) Required() bool
- func (f *Flag) Short() string
- func (f *Flag) Value() interface{}
- func (f *Flag) ValueBy() string
- func (f *Flag) ValueDefault() string
- func (f *Flag) ValueType() string
- type FlagSet
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command represents a command
type Flag ¶
type Flag struct {
// contains filtered or unexported fields
}
Flag represents a flag
func (*Flag) Description ¶
Description returns the description of the flag
func (*Flag) FieldIndex ¶ added in v1.0.1
FieldIndex returns the parent flag id of the flag
func (*Flag) FormattedArg ¶
FormattedArg returns the formatted argument of the flag
func (*Flag) ParentIndex ¶ added in v1.0.1
ParentIndex returns the parent flag id of the flag
func (*Flag) ValueDefault ¶
ValueDefault returns the default value of the flag
type FlagSet ¶
type FlagSet struct {
// contains filtered or unexported fields
}
FlagSet represents a flag set
func (*FlagSet) FlagArgs ¶
FlagArgs returns the flag arguments those exist in the argument list If the flag is an argument then it return it's values (i.e. [foo bar] for `-f=foo -f=bar`) If it's a command then it returns the command name and the rest of the arguments (i.e. [command -f=true --bar=baz qux] for `command -f --bar=baz qux`). Nested commands are separated by dot (i.e. Foo.Bar)
func (*FlagSet) FlagByArg ¶
FlagByArg returns a flag by the given argument name or returns nil if it doesn't exist Nested commands are separated by dot (i.e. Foo.Bar)
func (*FlagSet) FlagByName ¶
FlagByName returns a flag by the given name or returns nil if it doesn't exist Nested commands are separated by dot (i.e. Foo.Bar)
type Options ¶
type Options struct {
// Flags represent the user defined command line arguments and commands.
// When it's a struct type, each field represent an argument or command.
Flags interface{}
// Args hold command line arguments. Default is os.Args
Args []string
}
Options represents the options that can be set when creating a new flag set