Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrAmbiguous = errors.New("Command is ambiguous") ErrNotFound = errors.New("Command not found") )
Errors returned by the cmd package.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct {
Name string // command string
Brief string // brief description shown in a command list
Description string // long description shown with command help
Usage string // usage hint text
Shortcuts []string // command shortcuts
Subtree *Tree // the command's subtree of commands
Data interface{} // user-defined data for this command
}
A Command represents either a single named command or the root of a subtree of commands.
func (*Command) DisplayShortcuts ¶
DisplayShortcuts displays all shortcuts associated with the command.
func (*Command) DisplayUsage ¶
DisplayUsage outputs the command's usage string.
type Selection ¶
type Selection struct {
Command *Command // the selected command
Args []string // the command's white-space delimited arguments
}
A Selection represents the result of looking up a command in a command tree. It includes the whitespace-delimited arguments following the discovered command.
type Tree ¶
type Tree struct {
Title string // description of all commands in tree
Commands []*Command // all commands in the tree
// contains filtered or unexported fields
}
A Tree contains one or more commands which are grouped together and may be looked up by a shortest unambiguous prefix match.
func (*Tree) AddCommand ¶
AddCommand adds a command to a command tree.
func (*Tree) AddShortcut ¶
AddShortcut adds a shortcut to a command in the tree.
func (*Tree) DisplayCommands ¶
DisplayCommands displays the commands available at the tree's top level.
func (*Tree) DisplayHelp ¶
DisplayHelp parses the 'help' command's arguments string and displays an appropriate help response.