ms/packages/spring/src/command.ts
MiaoWoo e9a4f2f351 refactor: chat & command tabComplete
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-22 15:29:12 +08:00

29 lines
1.0 KiB
TypeScript

import '@ccms/nashorn'
import { command, plugin } from '@ccms/api'
import { inject, provideSingleton, postConstruct } from '@ccms/container'
import { CommandMap } from './internal/command'
@provideSingleton(command.Command)
export class SpringCommand extends command.Command {
@inject(CommandMap)
private commandMap: CommandMap
protected create(plugin: any, command: string) {
return this.commandMap.register(plugin, command)
}
public tabComplete(sender: any, input: string, index?: number): string[] {
return this.commandMap.tabComplate(sender, input, index)
}
protected remove(plugin: any, command: string) {
this.commandMap.unregister(plugin, command)
}
protected onCommand(plugin: any, command: any, executor: Function) {
command.setExecutor(super.setExecutor(plugin, command, executor))
}
protected onTabComplete(plugin: any, command: any, tabCompleter: Function) {
command.setTabCompleter(super.setTabCompleter(plugin, command, tabCompleter))
}
}