command

package
v0.7.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2015 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SINGLE_REGISTRATION = iota
	MULTI_REGISTRATION
)

Variables

View Source
var (
	CommandRegistry  = make(map[string]Command)
	AdminCmdRegistry = make(map[string]Command)
)

Functions

func Admin

func Admin(ctx *env.Context)

func Gem

func Gem(ctx *env.Context)

func Help

func Help(ctx *env.Context)

func List

func List(ctx *env.Context)

List all rubies registered with uru, identifying the currently active ruby

func Ruby

func Ruby(ctx *env.Context)

func Use

func Use(ctx *env.Context)

func Version

func Version(ctx *env.Context)

Types

type Command

type Command struct {
	Name    string
	Aliases []string
	Usage   string
	HelpMsg string
	Eg      string
}

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.

type HandlerFunc added in v0.7.7

type HandlerFunc func(*env.Context)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL