Commands
Configurations
When registering a command, you can configure its trigger name, alias, description, and list of subcommands, which Mustard supports in the form of parameter lists or objects:
@Command('run')
@Command('run', 'r')
@Command('run', 'run command handle')
@Command('run', 'r', 'run command handle')
@Command('run', [RunSubCommandHandle])
@Command({
name: 'run',
alias: 'r',
description: 'run command handle',
subCommands: [RunSubCommandHandle]
})
class RunCommandHandle implements CommandStruct {
public run() {}
}
To split
@Command('run', 'r')
and@Command('run', 'run command handle')
overloads, if you provide a string which length is less than 3, it will be treated as alias, otherwise it will be treated as description.
Nested Commands
Mustard supports infinite levels of nested commands, and you can also use @Command
decorator to register subcommands:
@Command('log')
class RunSyncLogCommandHandle implements CommandStruct {
public run() {}
}
@Command('sync', [RunSyncLogCommandHandle])
class RunSyncCommandHandle implements CommandStruct {
public run() {}
}
@Command('update')
class RunUpdateCommandHandle implements CommandStruct {
public run() {}
}
@Command('run', [RunSyncCommandHandle, RunUpdateCommandHandle])
class RunCommandHandle implements CommandStruct {
public run() {}
}
Table of Contents