Skip to content

Latest commit

 

History

History
261 lines (131 loc) · 2.9 KB

File metadata and controls

261 lines (131 loc) · 2.9 KB

sapi-pro


sapi-pro / Command

Class: Command

Constructors

Constructor

new Command(name, explain, isAdmin, handler?, validator?, isHidden?, isClient?): Command

构造新命令(复杂的推荐用Command.fromObject)

Parameters

name

string

命令名

explain

string

命令解释

isAdmin

boolean

是否管理员命令,默认否

handler?

commandHandler

命令处理器

validator?

CommandValidator

命令验证器

isHidden?

boolean = false

是否隐藏命令

isClient?

boolean = false

是否客户端命令(客户端行为包)

Returns

Command

Properties

explain

explain: string


handler?

optional handler?: commandHandler


isAdmin

isAdmin: boolean


isClientCommand?

optional isClientCommand?: boolean


isHidden

isHidden: boolean


name

name: string


paramBranches

paramBranches: ParamDefinition[] = []


subCommands

subCommands: Command[] = []


validator?

optional validator?: CommandValidator

Methods

addParam()

addParam(param): Command

添加一条分支并在其中添加一条参数

Parameters

param

ParamDefinition

Returns

Command


addParamBranches()

addParamBranches(param): Command

添加多个命令参数分支

Parameters

param

paramBranches[]

Returns

Command


addParams()

addParams(params): Command

添加一条参数分支的多个参数

Parameters

params

ParamDefinition[]

Returns

Command


addSubCommand()

addSubCommand(subCommand): Command

添加子命令

Parameters

subCommand

Command

Returns

Command


addSubCommands()

addSubCommands(subCommands): Command

添加一堆子命令

Parameters

subCommands

Command[]

Returns

Command


getFlatBranch()

getFlatBranch(): object

获取一条参数

Returns

object

mandatory

mandatory: CustomCommandParameter[] = branch

optional

optional: CustomCommandParameter[]


toNative()

toNative(nameSpace): CustomCommand

Parameters

nameSpace

string

Returns

CustomCommand


fromObject()

static fromObject(obj): Command

从Object创建命令

Parameters

obj

CommandObject

Returns

Command