cli

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicHelp

func BasicHelp(app *App, ts string) func() string

BasicHelp returns a function that creates a basic help text for the application with its commands.

Types

type App

type App struct {
	Name string
	Help func() string
	// contains filtered or unexported fields
}

App represents an application that may consist of multiple commands.

func NewApp

func NewApp(name string) *App

NewApp creates a new application with a pre-registered help command.

func (*App) Register

func (app *App) Register(name string, cmd *Command)

Register adds a new command to the application.

func (*App) Run

func (app *App) Run(t Term, args ...string) int

Run the application with the given arguments. Output is sent to t.

type Command

type Command struct {
	Desc string
	Run  func(t Term, args ...string) int
}

Command represents a single command within an application.

type Term

type Term interface {
	Infof(format string, v ...interface{})
	Errorf(format string, v ...interface{})
	Out() io.Writer
	Err() io.Writer
}

Term handles an application's output.

func BasicTerm

func BasicTerm(out, err io.Writer) Term

BasicTerm returns a Term writing Infof and Errorf to err and Out to out.

Jump to

Keyboard shortcuts

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