cli

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2018 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cli provides quick start framework for command line application.

The main features of Hiboot cli application are

* Dependency Injection * Struct Tag for dependency injection * Sub command handler

Index

Constants

This section is empty.

Variables

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

ErrCommandHandlerNotFound

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

ErrCommandNotFound command not found error

Functions

func Dispatch added in v0.9.0

func Dispatch(c Command, args []string) (retVal interface{}, err error)

Dispatch method with OnAction prefix

func Register

func Register(c Command)

Register register

Types

type Application

type Application interface {
	app.Application
	Root() Command
	SetRoot(root Command)
}

Application cli application interface

func NewApplication

func NewApplication(cmd ...interface{}) Application

NewApplication create new cli application

type BaseCommand

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

BaseCommand is the base command

func (*BaseCommand) Add

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

Add added child command

func (*BaseCommand) Children

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

Children get children

func (*BaseCommand) EmbeddedCommand

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

EmbeddedCommand get embedded command

func (*BaseCommand) Exec

func (c *BaseCommand) Exec() error

Exec exec method

func (*BaseCommand) Find

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

Find find child command

func (*BaseCommand) FullName

func (c *BaseCommand) FullName() string

FullName get command full name

func (*BaseCommand) GetName

func (c *BaseCommand) GetName() string

GetName get command name

func (*BaseCommand) HasChild

func (c *BaseCommand) HasChild() bool

HasChild check whether it has child or not

func (*BaseCommand) Parent

func (c *BaseCommand) Parent() Command

Parent get parent command

func (*BaseCommand) Run

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

Run method

func (*BaseCommand) SetFullName

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

SetFullName set command full name

func (*BaseCommand) SetName

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

SetName set command name

func (*BaseCommand) SetParent

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

SetParent set parent 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{}
}

CommandNameValue

type TestApplication

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

func NewTestApplication

func NewTestApplication(t *testing.T, cmd ...interface{}) TestApplication

NewTestApplication is the test application constructor

Jump to

Keyboard shortcuts

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