feat: update plugin register
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
4110ed2c20
commit
b87b94aade
@ -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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { injectable, postConstruct } from "inversify";
|
||||
import { injectable } from "@ms/container";
|
||||
|
||||
export namespace interfaces {
|
||||
@injectable()
|
||||
|
@ -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>();
|
||||
|
Loading…
Reference in New Issue
Block a user