cli

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommandNotFoundError = errors.New("command not found")

Functions

func AddCommand

func AddCommand(parentPath string, commands ...Command)

func Register

func Register(c Command)

Types

type Application

type Application interface {
	Run()
	Init(cmd ...Command) error
	Root() Command
	SetRoot(root Command)
}

func GetApplication

func GetApplication() Application

func NewApplication

func NewApplication(cmd ...Command) Application

type BaseCommand

type BaseCommand struct {
	cobra.Command
	// contains filtered or unexported fields
}

func (*BaseCommand) Add

func (c *BaseCommand) Add(commands ...Command) Command

func (*BaseCommand) Children

func (c *BaseCommand) Children() []Command

func (*BaseCommand) EmbeddedCommand

func (c *BaseCommand) EmbeddedCommand() *cobra.Command

func (*BaseCommand) Exec

func (c *BaseCommand) Exec() error

func (*BaseCommand) Find

func (c *BaseCommand) Find(name string) (Command, error)

func (*BaseCommand) FullName

func (c *BaseCommand) FullName() string

func (*BaseCommand) GetName

func (c *BaseCommand) GetName() string

func (*BaseCommand) HasChild

func (c *BaseCommand) HasChild() bool

func (*BaseCommand) Parent

func (c *BaseCommand) Parent() Command

func (*BaseCommand) Run

func (c *BaseCommand) Run(args []string) error

func (*BaseCommand) SetFullName

func (c *BaseCommand) SetFullName(name string) Command

func (*BaseCommand) SetName

func (c *BaseCommand) SetName(name string) Command

func (*BaseCommand) SetParent

func (c *BaseCommand) SetParent(p Command) Command

type Command

type Command interface {
	EmbeddedCommand() *cobra.Command
	Add(commands ...Command) Command
	HasChild() bool
	Children() []Command
	Exec() error
	GetName() string
	FullName() string
	SetName(name string) Command
	SetFullName(name string) Command
	Parent() Command
	SetParent(p Command) Command
	Run(args []string) error
	Find(name string) (Command, error)
	SetOutput(output io.Writer)
	SetArgs(a []string)
	ExecuteC() (cmd *cobra.Command, err error)
	PersistentFlags() *flag.FlagSet
}

type CommandNameValue

type CommandNameValue struct {
	Name    string
	Command interface{}
}

type TestApplication

type TestApplication interface {
	Application
	RunTest(args ...string) (output string, err error)
}

func NewTestApplication

func NewTestApplication(cmd ...Command) TestApplication

Jump to

Keyboard shortcuts

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