feat: update plugin register

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2019-11-04 20:28:52 +08:00
parent 4110ed2c20
commit b87b94aade
3 changed files with 6 additions and 5 deletions

View File

@ -35,12 +35,13 @@ export function cmd(metadata: interfaces.CommandMetadata = {}) {
}
/**
* MiaoScript Command
* @param metadata CommandMetadata
* MiaoScript TabComplete
* @param metadata TabCompleterMetadata
*/
export function tab(metadata: interfaces.TabCompleterMetadata = {}) {
return function(target: any, key: string, value: any) {
metadata.name = metadata.name || key.startsWith('tab') ? key.split('tab', 2)[0] : key;
metadata.name = metadata.name || (key.startsWith('tab') ? key.split('tab', 2)[1] : key);
if (!metadata.name) { return; }
metadata.executor = key;
metadata.paramtypes = Reflect.getMetadata("design:paramtypes", target, key)
const previousMetadata: Map<string, interfaces.TabCompleterMetadata> = getPluginTabCompleterMetadata(target)

View File

@ -1,4 +1,4 @@
import { injectable, postConstruct } from "inversify";
import { injectable } from "@ms/container";
export namespace interfaces {
@injectable()

View File

@ -34,7 +34,7 @@ function getPluginCommandMetadata(target: any) {
}
function getPluginTabCompleterMetadata(target: any) {
let tabcompleterMetadata: Map<string, interfaces.CommandMetadata> = Reflect.getMetadata(
let tabcompleterMetadata: Map<string, interfaces.TabCompleterMetadata> = Reflect.getMetadata(
METADATA_KEY.tab,
target.constructor
) || new Map<string, interfaces.TabCompleterMetadata>();