core

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: MIT Imports: 4 Imported by: ? 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

Index

Constants

View Source
const CommandKey = "Command"

Variables

This section is empty.

Functions

func CommanderRegisterFn

func CommanderRegisterFn(commander Commander, app *CmdApp)

默认commander 自动注册 到 cli 应用的方法

func CreateCommandByMap

func CreateCommandByMap(data map[string]interface{}) *cli.Command

func NewCommand

func NewCommand() *cli.Command

Types

type AutoInit

type AutoInit interface {
	Init()
}

自动初始化内部属性 和 方法

type BaseCommander

type BaseCommander struct {
	Command *cli.Command
	// contains filtered or unexported fields
}

func (*BaseCommander) Argument

func (commander *BaseCommander) Argument() CommanderArgument

func (*BaseCommander) Arguments

func (commander *BaseCommander) Arguments() (flags []cli.Flag)

func (*BaseCommander) Boot

func (commander *BaseCommander) Boot()

自定义引导

func (*BaseCommander) GetCommand

func (commander *BaseCommander) GetCommand() *cli.Command

获取 command 对象

func (*BaseCommander) Handle

func (commander *BaseCommander) Handle(ctx *cli.Context) error

请执行实现 处理逻辑

func (*BaseCommander) Init

func (commander *BaseCommander) Init()

初始化

func (*BaseCommander) InitCommand

func (commander *BaseCommander) InitCommand() *BaseCommander

构造新command

func (*BaseCommander) Register

func (commander *BaseCommander) Register(app *CmdApp)

必须自行实现注册 覆盖 BaseCommander

func (*BaseCommander) SetProperties

func (commander *BaseCommander) SetProperties(properties map[string]interface{})

通过 map 设置 command 相关参数

type BootAble

type BootAble interface {
	Boot()
}

自主 加载相关信息

type CmdApp

type CmdApp struct {
	cli.App
	// contains filtered or unexported fields
}

命令行应用

func NewCmdApp

func NewCmdApp() *CmdApp

func (*CmdApp) AppendCommand

func (cmd *CmdApp) AppendCommand(commander Commander, index ...int)

追加命令

func (*CmdApp) Init

func (cmd *CmdApp) Init()

初始化

func (*CmdApp) InsertCommand

func (cmd *CmdApp) InsertCommand(commander Commander) *CmdApp

添加command

func (*CmdApp) IsLoaded

func (cmd *CmdApp) IsLoaded(key string) bool

是否已加载

func (*CmdApp) IsLocked

func (cmd *CmdApp) IsLocked() bool

是否已经初始化 , 加载过

func (*CmdApp) Len

func (cmd *CmdApp) Len() int

命令数量

func (*CmdApp) Less

func (cmd *CmdApp) Less(i, j int) bool

func (*CmdApp) LoadCommands

func (cmd *CmdApp) LoadCommands(commanders ...Commander) *CmdApp

加载

func (*CmdApp) Run

func (cmd *CmdApp) Run() error

运行

func (*CmdApp) SetProperties

func (cmd *CmdApp) SetProperties(properties map[string]interface{})

设置 应用属性

func (*CmdApp) Swap

func (cmd *CmdApp) Swap(i, j int)

type CommandAutoRegister

type CommandAutoRegister interface {
	Register(app *CmdApp)
}

命令自动挂载

type Commander

type Commander interface {
	AutoInit
	BootAble
	CommandAutoRegister
	GetCommand() *cli.Command
	Argument() CommanderArgument
}

参数命令行

func NewCommander

func NewCommander(data map[string]interface{}) Commander

type CommanderArgument

type CommanderArgument interface {
	Arguments() []cli.Flag
	SetArguments([]cli.Flag)
	AddArgument(cli.Flag)
}

命令行参数器

func NewCommanderArgument

func NewCommanderArgument(cmd *cli.Command) CommanderArgument

type CommanderArguments

type CommanderArguments struct {
	Command *cli.Command
}

func (*CommanderArguments) AddArgument

func (args *CommanderArguments) AddArgument(arg cli.Flag)

func (*CommanderArguments) Arguments

func (args *CommanderArguments) Arguments() []cli.Flag

func (*CommanderArguments) SetArguments

func (args *CommanderArguments) SetArguments(lists []cli.Flag)

type CommanderHandler

type CommanderHandler interface {
	Handle(*cli.Context) error
}

命令处理逻辑函数接口

type MapPropertiesSetter

type MapPropertiesSetter interface {
	SetProperties(map[string]interface{})
}

通用属性设置

type Runner

type Runner interface {
	Run() error
}

Jump to

Keyboard shortcuts

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