cli

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2015 License: AGPL-3.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultCommands

func DefaultCommands(c *CLI) error

Types

type Binding

type Binding func(*CLI) error

Binding is a function for setting up new Commands from other packages.

type CLI

type CLI struct {
	Commands map[string]*Command

	Rl *readline.Instance
	// contains filtered or unexported fields
}

CLI is a set of Commands and their aliases.

func NewCLI

func NewCLI(bindings ...Binding) (*CLI, error)

func (*CLI) AddCommands

func (c *CLI) AddCommands(cms ...*Command) error

func (*CLI) Admin

func (c *CLI) Admin()

Admin reads commands from stdin and executes them.

type Command

type Command struct {
	Name, Description string
	Aliases           []string
	Fn                CommandFunc
}

Command is a CLI command which runs a given function Fn when the command is issued.

type CommandFunc

type CommandFunc func(...string) (Response, error)

CommandFunc is the type which a Command's Fn must be.

type Response

type Response string

Response is the type that returns from a Command.

Jump to

Keyboard shortcuts

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