Documentation
¶
Overview ¶
Package parameters provides an argument parser for dealing with a mix of quoted and unquoted arguments.
Index ¶
- type Flags
- func (f *Flags) Bool(name string, value bool, usage string)
- func (f *Flags) Float(name string, value float64, usage string)
- func (f *Flags) GetBool(name string) (val bool, ok bool)
- func (f *Flags) GetFloat64(name string) (val float64, ok bool)
- func (f *Flags) GetInt64(name string) (val int64, ok bool)
- func (f *Flags) GetString(name string) (val string, ok bool)
- func (f *Flags) Int(name string, value int64, usage string)
- func (f *Flags) Parse(args []string) string
- func (f *Flags) String(name string, value string, usage string)
- type Parameters
- func (p *Parameters) Args() []string
- func (p *Parameters) Flags() []string
- func (p *Parameters) FullCommand() string
- func (p *Parameters) HasNext() bool
- func (p *Parameters) Match(potentialMatches ...string) (string, bool)
- func (p *Parameters) MatchFlags(flags ...string) bool
- func (p *Parameters) Peek() string
- func (p *Parameters) PeekMatch(potentialMatches ...string) (string, bool)
- func (p *Parameters) PeekPtr(ptr int) (string, int)
- func (p *Parameters) Pop() string
- func (p *Parameters) Remainder(skipFlags bool) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Flags ¶
type Flags struct {
// contains filtered or unexported fields
}
func (*Flags) GetBool ¶
GetBool returns the flag called "name". ok is false if the flag is not found or if it isn't a boolean.
func (*Flags) GetFloat64 ¶
GetFloat64 returns the flag called "name". ok is false if the flag is not found or if it isn't a float.
func (*Flags) GetInt64 ¶
GetInt64 returns the flag called "name". ok is false if the flag is not found or if it isn't an int.
func (*Flags) GetString ¶
GetString returns the flag called "name". ok is false if the flag is not found or if it isn't a string.
type Parameters ¶
type Parameters struct {
// contains filtered or unexported fields
}
Parameters is an argument parser. It is not thread-safe.
func NewParameters ¶
func NewParameters(s string, matchFlags bool) *Parameters
NewParameters returns a new Parameters. If matchFlags is false, flags (unquoted arguments starting with -) will be treated the same as other arguments.
func (*Parameters) Args ¶
func (p *Parameters) Args() []string
Args returns all remaining arguments as a slice of strings. Use p.Remainder to return all remaining arguments as a single string.
func (*Parameters) Flags ¶
func (p *Parameters) Flags() []string
Flags returns p's parsed flags. if matchFlags is set to false, always returns nil.
func (*Parameters) FullCommand ¶
func (p *Parameters) FullCommand() string
FullCommand returns the full command passed into parameters.New.
func (*Parameters) HasNext ¶
func (p *Parameters) HasNext() bool
HasNext returns true if p has any parameters left.
func (*Parameters) Match ¶
func (p *Parameters) Match(potentialMatches ...string) (string, bool)
Match returns (match, true) if any of the arguments matched, and ("", false) if none did. If an argument matches, the matched string is popped from p.
func (*Parameters) MatchFlags ¶
func (p *Parameters) MatchFlags(flags ...string) bool
MatchFlags matches the given flags against the flags in p. Arguments should always be passed lowercase.
func (*Parameters) Peek ¶
func (p *Parameters) Peek() string
Peek returns the next argument in the parameters, but doesn't move the pointer.
func (*Parameters) PeekMatch ¶
func (p *Parameters) PeekMatch(potentialMatches ...string) (string, bool)
PeekMatch is like Match but doesn't pop the argument from p.
func (*Parameters) PeekPtr ¶
func (p *Parameters) PeekPtr(ptr int) (string, int)
PeekPtr is like Pop, but uses a user-supplied pointer rather than p's.
func (*Parameters) Pop ¶
func (p *Parameters) Pop() string
Pop returns the next argument in the parameters, skipping over flags.
func (*Parameters) Remainder ¶
func (p *Parameters) Remainder(skipFlags bool) string
Remainder returns the remaining arguments. skipFlags only has an effect if matchFlags is set to true.