Documentation
¶
Overview ¶
Package cliparser provides a simple parsing API for CLI.
Index ¶
- type Component
- type ComponentType
- type Parser
- func (p *Parser) Feed(args []string)
- func (p *Parser) GetComponent() *Component
- func (p *Parser) HintAlias(alias, name string, optNS ...[]string)
- func (p *Parser) HintCommand(name string, optNS ...[]string)
- func (p *Parser) HintDisableDoubleHyphen()
- func (p *Parser) HintLongName(name string, optNS ...[]string)
- func (p *Parser) HintNoOptionsGrouped()
- func (p *Parser) HintWithArg(name string, optNS ...[]string)
- func (p *Parser) Parse() error
- func (p *Parser) Reset()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component struct {
Type ComponentType
Name string
Arg string
}
Component is a resultant type of this package.
type ComponentType ¶
type ComponentType int
ComponentType represents the type of parsed component.
const ( // Unknown is not used in this package. Unknown ComponentType = iota // Option for -o -opt --opt Option // Command for command (requires call of Parser.HintCommand) Command // Arg is not an option nor a command. Arg )
func (ComponentType) String ¶
func (t ComponentType) String() string
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser contains parsing configurations and methods.
func (*Parser) GetComponent ¶
GetComponent returns a Component. At end of source stream, this returns nil.
func (*Parser) HintCommand ¶
HintCommand is for giving the parser hint that the name is command.
func (*Parser) HintDisableDoubleHyphen ¶ added in v0.2.0
func (p *Parser) HintDisableDoubleHyphen()
HintDisableDoubleHyphen disallows -abc -> -a -b -c
func (*Parser) HintLongName ¶
HintLongName is for giving the parser hint that the name is option has a long name even if ONE-HYPHEND (-hoge)
func (*Parser) HintNoOptionsGrouped ¶
func (p *Parser) HintNoOptionsGrouped()
HintNoOptionsGrouped disallows -abc -> -a -b -c
func (*Parser) HintWithArg ¶
HintWithArg is for giving the parser hint that the name is option and it requires an argument.