bin

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppMethodInit   = "Init"
	AppMethodRun    = "Run"
	AppMethodNoSubC = "SubCommandUnfind"
	AppMethodHelp   = "Help"
)

Variables

This section is empty.

Functions

func Adapter

func Adapter(router *Router)

加载路由器为适配器

func Alias added in v0.1.1

func Alias(cmd string, alias ...string)

* 命令别名集(单个)

func AliasMany added in v0.1.1

func AliasMany(alias map[string][]string)

* 命令别名集(多个)

func AmendSubC added in v0.4.1

func AmendSubC(subC string) string

修正文件命令

func CallCmdHelp added in v0.2.1

func CallCmdHelp(key string) bool

请求命令行帮助

func FormatStr added in v0.4.1

func FormatStr(d string, ss ...[][]string) string

获取字符串格式化 [[k, v]]

func Init

func Init(param []string)

* 初始化

func Register

func Register(name string, cmd interface{})

* 项目注册(单个)

func RegisterApps

func RegisterApps(data map[string]interface{})

* 注册多个项目

func Rwd added in v0.3.0

func Rwd() string

获取命令正在运行的代码

func SubCommand added in v0.1.1

func SubCommand(able bool)

二级命令配置

Types

type ActionInterface

type ActionInterface interface {
}

项目引用

type App

type App struct {
	Data   map[string]interface{}
	Router *Router

	Command    string   // 当前的命令
	SubCommand string   // 二级命令
	Setting    []string // 项目设置
	Queue      []string // 命令队列
	// contains filtered or unexported fields
}

func GetApp added in v0.1.1

func GetApp() App

获取命令行 App

func Run

func Run() App

系统运行

func (App) Cwd

func (app App) Cwd() string

* 获取当的工作目录

func (App) HasSetting added in v0.1.1

func (app App) HasSetting(set string) bool

* 检测属性是否存在

func (*App) Next added in v0.3.1

func (app *App) Next(keys ...string) string

多简直获取键值

func (*App) PrjName added in v0.1.1

func (app *App) PrjName() string

获取项目名称

func (*App) QueueNext added in v0.1.1

func (app *App) QueueNext(key string) string

队列右邻值

type Command

type Command struct {
	App App
	SCA *SubCmdAlias
}

命令结构体

func (*Command) Help added in v0.4.0

func (c *Command) Help()

帮助说明

func (*Command) Init

func (c *Command) Init()

引用初始化接口

func (*Command) InnerDistribute added in v0.2.0

func (c *Command) InnerDistribute()

入口/内部分发(Entrance)

func (*Command) Run

func (c *Command) Run()

运行应用

func (*Command) SubCommandUnfind added in v0.1.1

func (c *Command) SubCommandUnfind(subCmd string)

二级命令应用

type Router

type Router struct {
	// 别名映射组
	Alias          map[string]string
	UnfindAction   func(action string)           // 路由失败
	EmptyAction    func()                        // 路由失败
	OptionListener func(opt string, a *App) bool // 选项监听回调
}

func (*Router) GetAction

func (router *Router) GetAction(action string) string

获取 action参数

type SubCmdAlias added in v0.2.0

type SubCmdAlias struct {
	Alias   map[string][]string
	Matched bool
	Self    interface{}
}

二级命令别名

Jump to

Keyboard shortcuts

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