cli

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2016 License: GPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cli

type Cli struct {
	Prog        string
	Description string
	Stderr      io.Writer

	Usage func()
	// contains filtered or unexported fields
}

Cli represents a command line interface.

func New

func New(prog string, handlers ...Handler) *Cli

New instantiates a ready-to-use Cli

func (*Cli) CmdHelp

func (cli *Cli) CmdHelp(args ...string) error

CmdHelp displays information on a command.

If more than one command is specified, information is only shown for the first command.

Usage: cli help COMMAND or cli COMMAND --help

func (*Cli) Command

func (cli *Cli) Command(name string) func(...string) error

Command returns a command handler, or nil if the command does not exist

func (*Cli) Run

func (cli *Cli) Run(args ...string) error

Run executes the specified command

func (*Cli) Subcmd

func (cli *Cli) Subcmd(name string, synopses []string, description string, exitOnError bool) *flag.FlagSet

Subcmd is a subcommand of the main command. A subcommand represents an action that can be performed from the command line.

To see all available subcommands, run "cli --help".

type Handler

type Handler interface {
	Command(name string) func(...string) error
}

Handler holds the different commands Cli will call. It should have methods with names starting with `Cmd` like:

func (h myHandler) CmdFoo(args ...string) error

type Initializer

type Initializer interface {
	Initialize() error
}

Initializer can be optionally implemented by a Handler to initialize before each call to one of its commands.

Jump to

Keyboard shortcuts

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