UNPKG

@tsed/cli-core

Version:
34 lines (33 loc) 941 B
import { injectable } from "@tsed/di"; import { JsonSchema } from "@tsed/schema"; JsonSchema.add("prompt", function prompt(label) { this.customKey("x-label", label); return this; }) .add("when", function when(fn) { this.customKey("x-when", fn); return this; }) .add("opt", function opt(v) { this.customKey("x-opt", v); return this; }) .add("choices", function choices(choices) { this.customKey("x-choices", choices); return this; }); export function command(options) { if (!options.token) { return injectable(Symbol.for(`COMMAND_${options.name}`)) .type("command") .set("command", options) .factory(() => { return { ...options, $prompt: options.prompt, $exec: options.handler }; }); } return injectable(options.token).type("command").set("command", options); }