diff --git a/packages/plugin/src/decorators.ts b/packages/plugin/src/decorators.ts index 54700823..26f37166 100644 --- a/packages/plugin/src/decorators.ts +++ b/packages/plugin/src/decorators.ts @@ -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 = getPluginTabCompleterMetadata(target) diff --git a/packages/plugin/src/interfaces.ts b/packages/plugin/src/interfaces.ts index 3008eb35..ef817011 100644 --- a/packages/plugin/src/interfaces.ts +++ b/packages/plugin/src/interfaces.ts @@ -1,4 +1,4 @@ -import { injectable, postConstruct } from "inversify"; +import { injectable } from "@ms/container"; export namespace interfaces { @injectable() diff --git a/packages/plugin/src/utils.ts b/packages/plugin/src/utils.ts index 5d31e93f..1a463bce 100644 --- a/packages/plugin/src/utils.ts +++ b/packages/plugin/src/utils.ts @@ -34,7 +34,7 @@ function getPluginCommandMetadata(target: any) { } function getPluginTabCompleterMetadata(target: any) { - let tabcompleterMetadata: Map = Reflect.getMetadata( + let tabcompleterMetadata: Map = Reflect.getMetadata( METADATA_KEY.tab, target.constructor ) || new Map();