Documentation ¶
Overview ¶
轻量级命令行框架
Index ¶
- Constants
- func Adapter(router *Router)
- func Alias(cmd string, alias ...string)
- func AliasMany(alias map[string][]string)
- func AmendSubC(subC string) string
- func CallCmdHelp(key string) bool
- func EmptyFunc(todo func())
- func FormatQue(que []interface{}, prefs ...string) string
- func FormatStr(d string, ss ...[][]string) string
- func FormatTable(data [][]interface{}, args ...interface{}) string
- func Init(param []string)
- func InjectArgs(params ...string)
- func IsEmptyCmd() bool
- func Register(name string, cmd interface{})
- func RegisterApps(data map[string]interface{})
- func RegisterFunc(cmd string, todo func())
- func Rwd() string
- func StrParseData(v string) interface{}
- func SubCommand(able bool)
- func UnfindFunc(todo func(cmd string))
- type ActionInterface
- type App
- type CmdUitl
- type Command
- type Router
- type SubCmdAlias
Constants ¶
View Source
const ( AppMethodInit = "Init" AppMethodRun = "Run" AppMethodNoSubC = "SubCommandUnfind" AppMethodHelp = "Help" )
Variables ¶
This section is empty.
Functions ¶
func FormatTable ¶ added in v0.5.0
func FormatTable(data [][]interface{}, args ...interface{}) string
表格格式化 (data, bool) 是否使用 idx
func StrParseData ¶ added in v0.5.0
func StrParseData(v string) interface{}
app.Data 数据格式化 正则检查并被处理为对应的数据格式 --key='字符串参数 可含空格'/--key="'字符串参数 可含空格'" 去除标点,并且认为是字符串 --key=1,2,45,87,96,52,37 整形数组 解析的格式有: bool, int64, float64, string, []int, []string,[]float64, string
Types ¶
type App ¶
type App struct { Data map[string]interface{} // 格式化数据 DataRaw map[string]string // 原始数据,命令行的所有数据解析时都为字符串 Router *Router Command string // 当前的命令 SubCommand string // 二级命令 Setting []string // 项目设置 Queue []string // 命令队列 // contains filtered or unexported fields }
全局命令行实例,可通过 GetApp 获取
type CmdUitl ¶ added in v0.5.0
type CmdUitl struct {
// contains filtered or unexported fields
}
Command 协助方法 通过 cmdInst 与 命令程序解析
func (*CmdUitl) BaseSubCAlias ¶ added in v0.5.0
func (cu *CmdUitl) BaseSubCAlias(inst interface{}, alias map[string][]string) *SubCmdAlias
二级命令别名
type Command ¶
type Command struct { App App SCA *SubCmdAlias Util *CmdUitl }
命令结构体
func (*Command) InnerDistribute ¶ added in v0.2.0
func (c *Command) InnerDistribute()
入口/内部分发(Entrance)
func (*Command) SubCommandUnfind ¶ added in v0.1.1
二级命令应用
type Router ¶
type Router struct { // 别名映射组 Alias map[string]string UnfindAction func(action string) // 路由失败 EmptyAction func() // 路由失败 FuncAction func(action string, a *App) bool // 函数式action命名,快速实现 OptionListener func(opt string, a *App) bool // 选项监听回调 }
路由器基类
type SubCmdAlias ¶ added in v0.2.0
二级命令别名
Click to show internal directories.
Click to hide internal directories.