Documentation
¶
Index ¶
- Variables
- func ParseCommand(test string) (name, last string)
- type Alias
- type ArgType
- type Argument
- type Context
- type FormatBuilder
- func (b *FormatBuilder) Action(handler func(ctx *Context)) *FormatBuilder
- func (b *FormatBuilder) Alias(reg string, option map[string]string) *FormatBuilder
- func (b *FormatBuilder) Arguments(args string) *FormatBuilder
- func (b *FormatBuilder) Build() (func(), error)
- func (b *FormatBuilder) Option(opt string) *FormatBuilder
- func (b *FormatBuilder) SubCommand(format string) *FormatBuilder
- type Inst
- type Option
- type Registry
- type System
Constants ¶
This section is empty.
Variables ¶
View Source
var ( RegFormat = regexp.MustCompile(`^(?P<name>\w+?)(?P<args>(?: [<\[]\w+?(?::\w+?)?[>\]](?:=\w+?)? ?)*)$`) ArgumentRegFormat = regexp.MustCompile(`(?:<(?P<required_name>\w+?)(?::(?P<required_type>\w+?))?>|\[(?P<optional_name>\w+?)(?::(?P<optional_type>\w+?))?\])(?:=(?P<default>\w+))?`) OptionRegFormat = regexp.MustCompile(`^-(?P<short>\w+?) \[(?P<name>\w+?)(?::(?P<type>\w+?))?\](?:=(?P<default>\w+?))?$`) )
Functions ¶
func ParseCommand ¶
Types ¶
type Context ¶
type Context struct {
botc.MessageContext
Tokens []string
Command string
ArgumentString string
Args map[string]string
Options map[string]string
}
func NewCommandContext ¶
func NewCommandContext(msg botc.MessageContext, text string) *Context
type FormatBuilder ¶
type FormatBuilder struct {
// contains filtered or unexported fields
}
func NewCommandFormatBuilder ¶
func NewCommandFormatBuilder(format string, callback func(Inst) func()) *FormatBuilder
func (*FormatBuilder) Action ¶
func (b *FormatBuilder) Action(handler func(ctx *Context)) *FormatBuilder
func (*FormatBuilder) Alias ¶
func (b *FormatBuilder) Alias(reg string, option map[string]string) *FormatBuilder
func (*FormatBuilder) Arguments ¶
func (b *FormatBuilder) Arguments(args string) *FormatBuilder
func (*FormatBuilder) Option ¶
func (b *FormatBuilder) Option(opt string) *FormatBuilder
func (*FormatBuilder) SubCommand ¶
func (b *FormatBuilder) SubCommand(format string) *FormatBuilder
SubCommand 创建子命令
type Inst ¶
type Inst struct {
Name string
Options []Option
Arguments []Argument
Alias map[string]map[string]string
Subs map[string]Inst
// contains filtered or unexported fields
}
func (Inst) CheckAlias ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewCommandRegistry ¶
func (*Registry) CheckAlias ¶
Click to show internal directories.
Click to hide internal directories.