commands

package
v2.3.0-pre6+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2016 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NameRe          = "[\\w.][\\w.-]*"
	OwnerRe         = "[a-zA-Z0-9][a-zA-Z0-9-]*"
	NameWithOwnerRe = fmt.Sprintf("^(?:%s|%s\\/%s)$", NameRe, OwnerRe, NameRe)

	CmdRunner = NewRunner()
)
View Source
var EnableAutoUpdate = false

Functions

This section is empty.

Types

type Args

type Args struct {
	Executable  string
	GlobalFlags []string
	Command     string
	ProgramPath string
	Params      []string

	Noop       bool
	Terminator bool

	Callbacks []func() error
	// contains filtered or unexported fields
}

func NewArgs

func NewArgs(args []string) *Args

func (*Args) After

func (a *Args) After(command ...string)

func (*Args) AfterFn

func (a *Args) AfterFn(fn func() error)

func (*Args) AppendParams

func (a *Args) AppendParams(params ...string)

func (*Args) Before

func (a *Args) Before(command ...string)

func (*Args) Commands

func (a *Args) Commands() []*cmd.Cmd

func (*Args) FirstParam

func (a *Args) FirstParam() string

func (*Args) GetParam

func (a *Args) GetParam(i int) string

func (*Args) HasFlags

func (a *Args) HasFlags(flags ...string) bool

func (*Args) HasSubcommand

func (a *Args) HasSubcommand() bool

func (*Args) IndexOfParam

func (a *Args) IndexOfParam(param string) int

func (*Args) InsertParam

func (a *Args) InsertParam(i int, items ...string)

func (*Args) IsParamsEmpty

func (a *Args) IsParamsEmpty() bool

func (*Args) LastParam

func (a *Args) LastParam() string

func (*Args) NoForward

func (a *Args) NoForward()

func (*Args) ParamsSize

func (a *Args) ParamsSize() int

func (*Args) PrependParams

func (a *Args) PrependParams(params ...string)

func (*Args) RemoveParam

func (a *Args) RemoveParam(i int) string

func (*Args) Replace

func (a *Args) Replace(executable, command string, params ...string)

func (*Args) ReplaceParam

func (a *Args) ReplaceParam(i int, item string)

func (*Args) ToCmd

func (a *Args) ToCmd() *cmd.Cmd

func (*Args) Words

func (a *Args) Words() []string

type Command

type Command struct {
	Run  func(cmd *Command, args *Args)
	Flag flag.FlagSet

	Key          string
	Usage        string
	Long         string
	GitExtension bool
	// contains filtered or unexported fields
}

func (*Command) Arg

func (c *Command) Arg(idx int) string

func (*Command) Call

func (c *Command) Call(args *Args) (err error)

func (*Command) FlagPassed

func (c *Command) FlagPassed(name string) bool

func (*Command) HelpText

func (c *Command) HelpText() string

func (*Command) Name

func (c *Command) Name() string

func (*Command) Runnable

func (c *Command) Runnable() bool

func (*Command) Synopsis

func (c *Command) Synopsis() string

func (*Command) Use

func (c *Command) Use(subCommand *Command)

type ExecError

type ExecError struct {
	Err      error
	Ran      bool
	ExitCode int
}

func (*ExecError) Error

func (execError *ExecError) Error() string

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner() *Runner

func (*Runner) All

func (r *Runner) All() map[string]*Command

func (*Runner) Call

func (r *Runner) Call(cmd *Command, args *Args) ExecError

func (*Runner) Execute

func (r *Runner) Execute() ExecError

func (*Runner) Lookup

func (r *Runner) Lookup(name string) *Command

func (*Runner) Use

func (r *Runner) Use(command *Command, aliases ...string)

type Updater

type Updater struct {
	Host           string
	CurrentVersion string
	// contains filtered or unexported fields
}

func NewUpdater

func NewUpdater() *Updater

func (*Updater) PromptForUpdate

func (updater *Updater) PromptForUpdate() (err error)

func (*Updater) Update

func (updater *Updater) Update() (err error)

Jump to

Keyboard shortcuts

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