Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandInterface ¶
type CommandInterface interface { // Execute function will be executed when the command is called Execute() // Description is used to display the "one-liner" help message in genera help Description() string // ArgumentDescription is used in general help ArgumentDescription() string // Help output would be a human readable long command specific help message Help() string // Examples is an array of possible calls Examples() []string }
CommandInterface defined a command. If a struct implements all the required function, it is acceptable as a Command for CommandRegistry
type CommandRegistry ¶
type CommandRegistry struct { Commands map[string]CommandInterface // contains filtered or unexported fields }
CommandRegistry will handle all CLI request and find the route to the proper Command
func NewCommandRegistry ¶
func NewCommandRegistry() *CommandRegistry
NewCommandRegistry is a simple "constructor"-like function that initializes Commands map
func (*CommandRegistry) CommandHelp ¶
func (c *CommandRegistry) CommandHelp(name string)
CommandHelp prints more detailed help for a specific Command
func (*CommandRegistry) Execute ¶
func (c *CommandRegistry) Execute()
Execute finds the proper command, handle errors from the command and print Help if the given command it unknown or print the Command specific help if something went wrong or the user asked for it.
func (*CommandRegistry) Help ¶
func (c *CommandRegistry) Help()
Help lists all available commands to the user
func (*CommandRegistry) Register ¶
func (c *CommandRegistry) Register(name string, handler CommandInterface)
Register function is used to register a Command in CommandRegistry the first argument will be the command from the CLI the second argument will be the handler that implements CommandInterface