Documentation
¶
Index ¶
- Constants
- Variables
- func Args() (args []*flag.Flag)
- func BindBootHandler(handler func(app *SimpleCommanderApp))
- func BuildFlagByArgInfoStrArr(info []string) cli.Flag
- func DeleteByIndex(arr []string, index int) []string
- func FilterArrString(arr []string) []string
- func FlagAppend(typeName string, name string, usage string, defs ...interface{}) (string, interface{})
- func Get(key string) string
- func GetArgN(i int) string
- func GetBigInt(key string) int64
- func GetBool(key string) bool
- func GetFlagNames(names string) (map[string]interface{}, bool)
- func GetFlagType(ty string) (map[string]string, bool)
- func GetFloat(key string) float64
- func GetInt(key string) int
- func GetName() string
- func GetNum(key string) int
- func GetOsArgN(i int) string
- func GetOsArgs() []string
- func GetValue(key string) interface{}
- func ReleaseStdout(stdout *os.File, tmp *os.File)
- func Run()
- func SliceFlags(row string, slice string) (arr []string)
- func Str2Bool(str string) bool
- func Str2Float64(str string) float64
- func Str2Int(str string) int
- func Str2IntArray(nums string) []int
- func Str2IntSlice(str string) (arr *cli.IntSlice)
- func TemplateParse(tplName string, tplContent string, v interface{}, funcMaps ...template.FuncMap) string
- type CommanderAppDto
- type CommanderFlagDto
- type FlagResolver
- type FlagsStrWrapper
- func (wrapper *FlagsStrWrapper) Args() (flags []cli.Flag)
- func (wrapper *FlagsStrWrapper) GetSlice() string
- func (wrapper *FlagsStrWrapper) Parse()
- func (wrapper *FlagsStrWrapper) Row() interface{}
- func (wrapper *FlagsStrWrapper) SetSlice(slice string) FlagResolver
- func (wrapper *FlagsStrWrapper) String() string
- type IniParser
- type Local
- type SimpleCommanderApp
- func (app *SimpleCommanderApp) AddFlag(ty string, name string, usage string, defs ...interface{})
- func (app *SimpleCommanderApp) AddFlagsByStrExpress(tpl string)
- func (app *SimpleCommanderApp) Args() (args []*flag.Flag)
- func (app *SimpleCommanderApp) Boot()
- func (app *SimpleCommanderApp) Get(key string) string
- func (app *SimpleCommanderApp) GetArgN(i int) string
- func (app *SimpleCommanderApp) GetBigInt(key string) int64
- func (app *SimpleCommanderApp) GetBool(key string) bool
- func (app *SimpleCommanderApp) GetFloat(key string) float64
- func (app *SimpleCommanderApp) GetInt(key string) int
- func (app *SimpleCommanderApp) GetName() string
- func (app *SimpleCommanderApp) GetNum(key string) int
- func (app *SimpleCommanderApp) GetOsArgN(i int) string
- func (app *SimpleCommanderApp) GetOsArgs() []string
- func (app *SimpleCommanderApp) GetUsage() func()
- func (app *SimpleCommanderApp) GetValue(key string) interface{}
- func (app *SimpleCommanderApp) HasArg(key string) bool
- func (app *SimpleCommanderApp) HelpBoot()
- func (app *SimpleCommanderApp) HelpWrapper(usage string) func()
- func (app *SimpleCommanderApp) Init()
- func (app *SimpleCommanderApp) Parse() bool
- func (app *SimpleCommanderApp) PrintUsage()
- func (app *SimpleCommanderApp) Run()
- func (app *SimpleCommanderApp) Usage2Str() string
- type SimpleCommanderAppApi
- type SimpleResolver
- type StringFlags
Examples ¶
Constants ¶
View Source
const CommandEnHelper = `` /* 264-byte string literal not displayed */
View Source
const CommandZhHelper = `` /* 273-byte string literal not displayed */
View Source
const DefStrFlagDiv = `:`
View Source
const DefStrFlagLineDiv = `\n`
View Source
const DefStrFlagLineRune rune = '\n'
View Source
const ROOT = "global"
View Source
const StrFlagHidden rune = '#'
View Source
const StrFlagRequired rune = '@'
View Source
const TypeRegexpPattern = `^\[([a-z]+)\]`
Variables ¶
View Source
var SimpleCommandLine = &SimpleCommanderApp{}
Functions ¶
func BindBootHandler ¶
func BindBootHandler(handler func(app *SimpleCommanderApp))
func BuildFlagByArgInfoStrArr ¶
func BuildFlagByArgInfoStrArr(info []string) cli.Flag
func DeleteByIndex ¶
func FilterArrString ¶
func FlagAppend ¶
func GetFlagNames ¶
func SliceFlags ¶
func Str2Float64 ¶
func Str2IntArray ¶
func Str2IntSlice ¶
func Str2IntSlice(str string) (arr *cli.IntSlice)
Types ¶
type CommanderAppDto ¶
type CommanderAppDto struct { Arguments []*CommanderFlagDto Usage string Name string Desc string Version string File string }
命令行应用 体 数据结构
func NewCommanderAppDto ¶
func NewCommanderAppDto() *CommanderAppDto
func (*CommanderAppDto) InitDto ¶
func (appDto *CommanderAppDto) InitDto(app *SimpleCommanderApp) *CommanderAppDto
type CommanderFlagDto ¶
type CommanderFlagDto struct { Name string Usage string DefaultValue interface{} Value interface{} RowType string }
命令参数 数据结构
func BuildFlagDtoByArgInfoStrArr ¶
func BuildFlagDtoByArgInfoStrArr(info []string) *CommanderFlagDto
func NewCommanderFlagDto ¶
func NewCommanderFlagDto() *CommanderFlagDto
func ParseFlagsExpress ¶
func ParseFlagsExpress(express string) []*CommanderFlagDto
func (*CommanderFlagDto) InitFlagDto ¶
func (flagDto *CommanderFlagDto) InitFlagDto(name, rowType, usage string, value interface{}, defValue interface{}) *CommanderFlagDto
初始化
type FlagResolver ¶
type FlagResolver interface { fmt.Stringer Row() interface{} Args() []cli.Flag SetSlice(string) FlagResolver GetSlice() string }
func NewFlagsStrWrapper ¶
func NewFlagsStrWrapper(str ...interface{}) FlagResolver
func StrTemplateResolver ¶
func StrTemplateResolver(template string, slice ...string) FlagResolver
type FlagsStrWrapper ¶
type FlagsStrWrapper struct { RowStr StringFlags Slice string ArgArr []cli.Flag }
func StrFlagsWrapper ¶
func StrFlagsWrapper(flags StringFlags, slice ...string) *FlagsStrWrapper
func (*FlagsStrWrapper) Args ¶
func (wrapper *FlagsStrWrapper) Args() (flags []cli.Flag)
func (*FlagsStrWrapper) GetSlice ¶
func (wrapper *FlagsStrWrapper) GetSlice() string
func (*FlagsStrWrapper) Parse ¶
func (wrapper *FlagsStrWrapper) Parse()
func (*FlagsStrWrapper) Row ¶
func (wrapper *FlagsStrWrapper) Row() interface{}
func (*FlagsStrWrapper) SetSlice ¶
func (wrapper *FlagsStrWrapper) SetSlice(slice string) FlagResolver
func (*FlagsStrWrapper) String ¶
func (wrapper *FlagsStrWrapper) String() string
type IniParser ¶
func NewIniParser ¶
func NewIniParser() *IniParser
func (*IniParser) ParserIniFile ¶
type SimpleCommanderApp ¶
type SimpleCommanderApp struct { Usage interface{} // 用户帮助说明 AutoParse bool // 是否初始时自动解析 Parsed bool // 是否已经解析 Name string // 命令应用名 Desc string // 命令应用描述 Lang Local // 语言 ArgumentMap map[string]*CommanderFlagDto // 参数存储容器 BootHandler func(app *SimpleCommanderApp) }
func NewSimpleCommanderAppByMap ¶
func NewSimpleCommanderAppByMap(data map[string]interface{}) *SimpleCommanderApp
func (*SimpleCommanderApp) AddFlag ¶
func (app *SimpleCommanderApp) AddFlag(ty string, name string, usage string, defs ...interface{})
func (*SimpleCommanderApp) AddFlagsByStrExpress ¶
func (app *SimpleCommanderApp) AddFlagsByStrExpress(tpl string)
func (*SimpleCommanderApp) Args ¶
func (app *SimpleCommanderApp) Args() (args []*flag.Flag)
func (*SimpleCommanderApp) Boot ¶
func (app *SimpleCommanderApp) Boot()
func (*SimpleCommanderApp) Get ¶
func (app *SimpleCommanderApp) Get(key string) string
func (*SimpleCommanderApp) GetArgN ¶
func (app *SimpleCommanderApp) GetArgN(i int) string
func (*SimpleCommanderApp) GetBigInt ¶
func (app *SimpleCommanderApp) GetBigInt(key string) int64
func (*SimpleCommanderApp) GetBool ¶
func (app *SimpleCommanderApp) GetBool(key string) bool
func (*SimpleCommanderApp) GetFloat ¶
func (app *SimpleCommanderApp) GetFloat(key string) float64
func (*SimpleCommanderApp) GetInt ¶
func (app *SimpleCommanderApp) GetInt(key string) int
func (*SimpleCommanderApp) GetName ¶
func (app *SimpleCommanderApp) GetName() string
func (*SimpleCommanderApp) GetNum ¶
func (app *SimpleCommanderApp) GetNum(key string) int
func (*SimpleCommanderApp) GetOsArgN ¶
func (app *SimpleCommanderApp) GetOsArgN(i int) string
func (*SimpleCommanderApp) GetOsArgs ¶
func (app *SimpleCommanderApp) GetOsArgs() []string
func (*SimpleCommanderApp) GetUsage ¶
func (app *SimpleCommanderApp) GetUsage() func()
func (*SimpleCommanderApp) GetValue ¶
func (app *SimpleCommanderApp) GetValue(key string) interface{}
func (*SimpleCommanderApp) HasArg ¶
func (app *SimpleCommanderApp) HasArg(key string) bool
func (*SimpleCommanderApp) HelpBoot ¶
func (app *SimpleCommanderApp) HelpBoot()
func (*SimpleCommanderApp) HelpWrapper ¶
func (app *SimpleCommanderApp) HelpWrapper(usage string) func()
func (*SimpleCommanderApp) Init ¶
func (app *SimpleCommanderApp) Init()
func (*SimpleCommanderApp) Parse ¶
func (app *SimpleCommanderApp) Parse() bool
func (*SimpleCommanderApp) PrintUsage ¶
func (app *SimpleCommanderApp) PrintUsage()
func (*SimpleCommanderApp) Run ¶
func (app *SimpleCommanderApp) Run()
func (*SimpleCommanderApp) Usage2Str ¶
func (app *SimpleCommanderApp) Usage2Str() string
type SimpleCommanderAppApi ¶
type SimpleResolver ¶
type SimpleResolver interface { Args() []*flag.Flag core.AutoInit core.BootAble GetUsage() func() GetName() string HelpBoot() Parse() bool }
func NewSimpleCommanderApp ¶
func NewSimpleCommanderApp() SimpleResolver
Example ¶
SimpleCommandLine.BootHandler = func(app *SimpleCommanderApp) { app.AddFlagsByStrExpress(FlagsExpress) } // SimpleCommandLine.Usage2Str() //SimpleCommandLine.PrintUsage() SimpleCommandLine.Parse() SimpleCommandLine.Get("name")
Output:
type StringFlags ¶
type StringFlags string
func Str2FlagTemplate ¶
func Str2FlagTemplate(str string) StringFlags
func (StringFlags) Resolver ¶
func (s StringFlags) Resolver() FlagResolver
func (StringFlags) String ¶
func (s StringFlags) String() string
Click to show internal directories.
Click to hide internal directories.