import { Context, isUndefined } from "@ipare/core"; import { Ctx } from "@ipare/pipe"; export class CommandService { @Ctx private readonly ctx!: Context; getOptionVlaue( commands: string[] | string ): T | undefined; getOptionVlaue( commands: string[] | string, defaultVal: T ): T; getOptionVlaue( commands: string[] | string, defaultVal?: T ): T | undefined { if (!Array.isArray(commands)) { commands = [commands]; } for (const property of commands) { if (!isUndefined(this.ctx.commandOptions[property])) { return this.ctx.commandOptions[property] as unknown as T; } } return defaultVal; } }