commands

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UndoIdentity int64 = 0x800001

UndoIdentity undo identity

Functions

func DefaultSourceParserFunc

func DefaultSourceParserFunc(valuetype string, input string) (value interface{}, err error)

DefaultSourceParserFunc parse input and assign value

func DefaultValidFunc

func DefaultValidFunc(valuetype string, input string, strict bool) bool

DefaultValidFunc default valic func when custom valid func is nil

Types

type CommandIterator

type CommandIterator struct {
	Expression      string
	CommandKeywords []string
	// contains filtered or unexported fields
}

CommandIterator command iterator

func NewCommandIterator

func NewCommandIterator(expression string) (iter *CommandIterator)

NewCommandIterator 创建辛的迭代器

func (*CommandIterator) Backup

func (ci *CommandIterator) Backup()

Backup 备份

func (*CommandIterator) First

func (ci *CommandIterator) First() bool

First whether it is first element

func (*CommandIterator) HasVisualCharactor

func (ci *CommandIterator) HasVisualCharactor() bool

Last whether it is last element

func (*CommandIterator) Last

func (ci *CommandIterator) Last() bool

Last whether it is last element

func (*CommandIterator) Next

func (ci *CommandIterator) Next() (command string, err error)

Next 命令获取下一个

func (*CommandIterator) Reset

func (ci *CommandIterator) Reset()

Reset reset from 0

func (*CommandIterator) Restore

func (ci *CommandIterator) Restore()

Restore 恢复

type CommandList

type CommandList struct {
	CommandWordGroups []CommandWordGroup
}

CommandList 命令参数

type CommandWord

type CommandWord struct {
	CommandWordDef
	RequireCommands []CommandWord //必须的命令字
}

CommandWord 命令参数

type CommandWordDef

type CommandWordDef struct {
	Identity     int64            // 命令字的ID
	Name         string           // 命令行助记符
	Helper       string           // 命令行帮助提示
	Type         string           // 如果是 Name,就用助记符比较,如果是 Value,则用 Value 比较
	ValueType    string           // 值类型, bool, integer, string
	Value        interface{}      // 携带的值,初始值为默认值
	DefaultValue interface{}      // 初始值为默认值
	SourceParser SourceParserFunc // 源解析函数,通过输入
	ValidFunc    ValidFunc        // 值校验函数
}

CommandWordDef define command keyword

var DebugCommandDef CommandWordDef = CommandWordDef{
	Name:   "debugging",
	Helper: "debugging operation",
	Type:   "name",
}

DebugCommandDef debug command define

var ResetCommandDef CommandWordDef = CommandWordDef{
	Name:   "reset",
	Helper: "reset operation",
	Type:   "name",
}

ResetCommandDef reset command define

var ShowCommandDef CommandWordDef = CommandWordDef{
	Name:   "show",
	Helper: "show operation",
	Type:   "name",
}

ShowCommandDef show information

var UndoCommandDef CommandWordDef = CommandWordDef{
	Identity: UndoIdentity,
	Name:     "undo",
	Helper:   "undo operation",
	Type:     "name",
}

UndoCommandDef undo operation

func (*CommandWordDef) MatchCommandDef

func (cw *CommandWordDef) MatchCommandDef(command string, strict bool) bool

MatchCommandDef 判断是否匹配

func (*CommandWordDef) MatchCommandDefByName

func (cw *CommandWordDef) MatchCommandDefByName(command string, strict bool) bool

MatchCommandDefByName match by name

func (*CommandWordDef) MatchCommandDefByValue

func (cw *CommandWordDef) MatchCommandDefByValue(command string, strict bool) bool

MatchCommandDefByValue match by value

type CommandWordDefElem

type CommandWordDefElem struct {
	CommandWordDefs []CommandWordDef
}

CommandWordDefElem 命令元组

type CommandWordGroup

type CommandWordGroup struct {
	Type                string
	IsWild              bool
	CommandWordDefElems []CommandWordDefElem
}

CommandWordGroup 元组

type SourceParserFunc

type SourceParserFunc func(valuetype string, input string) (value interface{}, err error)

SourceParserFunc func

type ValidFunc

type ValidFunc func(valuetype string, input string, strict bool) bool

ValidFunc func

Jump to

Keyboard shortcuts

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