Documentation ¶
Overview ¶
Package Commands provides common definitions & functionality for a CLI tool subcommand implementations
Index ¶
- type Command
- type Handler
- type Map
- func (cmds *Map) Add(name, descr string, handler Handler) *Command
- func (cmds *Map) Get(cmdName string) *Command
- func (cmds *Map) GetCommand() (cmd *Command, cmdArgs []string)
- func (cmds *Map) GetIdx(cmdName string) (cmd *Command, idx int)
- func (cmds *Map) HandleCommand() (exitCode int, err error)
- func (cmds *Map) Usage()
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 related data
func (*Command) Description ¶
type Map ¶
Map of Commands keyed by a normalized command name. Provides a global table of all registered subcommands
func (*Map) GetCommand ¶
GetCommand returns first command line command (non-flag argument) if any & its list of arguments
func (*Map) GetIdx ¶
GetIdx finds & returns a command with cmdName and it's index in the command line. Returns (nil, idx) if not found
func (*Map) HandleCommand ¶
HandleCommand parses command line & handles first found command with its arguments it returns command exit code with nil error if successful or error if command is not registered/invalid HandleCommand also prints help/usage into stdout if command is missing or is help/h