Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cli ¶
type Cli interface {
OneCmd(input string) error // Process one command
AddCmd(commands ...*Command) // Adds one or more commands
}
Cli command processer
type Command ¶
type Command struct {
Use string
Flags []*CommandFlag
Desc Description
Run func(flags map[string]*ParsedCommandFlags, args []string)
}
Command structure representing a command
func (*Command) GetFlag ¶
func (c *Command) GetFlag(flag string) *CommandFlag
Returns a flag by type name. Returns a flag by type name. If it does not exist, then nil.
type CommandFlag ¶
type CommandFlag struct {
Type string // flag id
Long string // for '--flag'
Short string // for '-f'
Desc Description
}
CommandFlag structure representing flag for command
type CommandParser ¶
type CommandParser interface {
ParseCommand(input string) (*ParsedCommand, error) // ParseCommand parses a string representing a command of the form <command> <flags> <args>
}
CommandParser implements a method for parsing commands of the form <command> <flags> <args> into a ParsedCommand structure
func NewCommandParser ¶
func NewCommandParser() CommandParser
type Description ¶
Description of command or flag or something else
type ParsedCommand ¶
type ParsedCommand struct {
Name string // same as Use in Command
Flags map[string]*ParsedCommandFlags
Args []string
}
type ParsedCommandFlags ¶
Click to show internal directories.
Click to hide internal directories.