Documentation
¶
Index ¶
Constants ¶
const ( SINGLE_REGISTRATION = iota MULTI_REGISTRATION )
Variables ¶
Functions ¶
Types ¶
type CommandRouter ¶ added in v0.7.7
type CommandRouter struct {
// contains filtered or unexported fields
}
func NewRouter ¶ added in v0.7.7
func NewRouter(handler HandlerFunc) *CommandRouter
Returns a newly configured, ready-to-use command router. Provide a default handler function that will be called when no predefined commands can be matched against the user specified command string. Most often used when creating a top-level command router in which arbitrary tokens are used to activate a particular ruby runtime.
If the default handler function is nil, the function will never be called.
func (*CommandRouter) Dispatch ¶ added in v0.7.7
func (r *CommandRouter) Dispatch(ctx *env.Context, cmd string)
Dispatch calls a previously bound function corresponding to the user specified command string, passing a context as the only arg. If the command string is not a recognized command, and the CommandRouter instance has been created with a non-nil default handler, the default handler will be invoked with a context as the only arg.
func (*CommandRouter) Handle ¶ added in v0.7.7
func (r *CommandRouter) Handle(cmds []string, handler HandlerFunc)
Handle binds a function to a set of user CLI command alias strings. The bound function is be executed whenever a user specifies one of the command aliases.