import {Args, Params} from "./units.js" import {CommandAnalysis} from "./analysis.js" import {validateCommand} from "../utils/validate-command.js" export type CommandTree = Command | {[key: string]: CommandTree} export type CommandOptions = { args: A params: P help?: string extraArgs?: {name: string, help?: string} execute?: (analysis: CommandAnalysis>) => Promise } export class Command { args: A params: P help: string | undefined extraArgs?: {name: string, help?: string} execute: (analysis: CommandAnalysis>) => Promise constructor(o: CommandOptions) { this.args = o.args this.params = o.params this.help = o.help this.extraArgs = o.extraArgs this.execute = o.execute ?? (async() => {}) validateCommand(this as Command) } }