commands

package
v2.8.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2019 License: MIT Imports: 20 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()
)

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
	Flag      *utils.ArgsParser
	// 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) 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)

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

func (*Command) Call

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

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) UsageError

func (c *Command) UsageError(msg string) error

func (*Command) Use

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

type ErrHelp

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

func (ErrHelp) Error

func (e ErrHelp) 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) Execute

func (r *Runner) Execute(cliArgs []string) error

func (*Runner) Lookup

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

func (*Runner) Use

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

Jump to

Keyboard shortcuts

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