type ArgType = "boolean" | "string" | "positional" | undefined; type _ArgDef = { type?: T; description?: string; valueHint?: string; alias?: string | string[]; default?: VT; required?: boolean; }; type BooleanArgDef = _ArgDef<"boolean", boolean>; type StringArgDef = _ArgDef<"string", string>; type PositionalArgDef = Omit<_ArgDef<"positional", string>, "alias">; type ArgDef = BooleanArgDef | StringArgDef | PositionalArgDef; type ArgsDef = Record; type Arg = ArgDef & { name: string; alias: string[]; }; type ParsedArgs = { _: string[]; } & Record<{ [K in keyof T]: T[K] extends { type: "positional"; } ? K : never; }[keyof T], string> & Record<{ [K in keyof T]: T[K] extends { type: "string"; } ? K : never; }[keyof T], string> & Record<{ [K in keyof T]: T[K] extends { type: "boolean"; } ? K : never; }[keyof T], boolean> & Record; interface CommandMeta { name?: string; version?: string; description?: string; } type SubCommandsDef = Record>>; type CommandDef = { meta?: Resolvable; args?: Resolvable; subCommands?: Resolvable; setup?: (context: CommandContext) => any | Promise; cleanup?: (context: CommandContext) => any | Promise; run?: (context: CommandContext) => any | Promise; }; type CommandContext = { rawArgs: string[]; args: ParsedArgs; cmd: CommandDef; subCommand?: CommandDef; data?: any; }; type Awaitable = () => T | Promise; type Resolvable = T | Promise | (() => T) | (() => Promise); declare function defineCommand(def: CommandDef): CommandDef; interface RunCommandOptions { rawArgs: string[]; data?: any; showUsage?: boolean; } declare function runCommand(cmd: CommandDef, opts: RunCommandOptions): Promise<{ result: unknown; }>; declare function showUsage(cmd: CommandDef, parent?: CommandDef): Promise; declare function renderUsage(cmd: CommandDef, parent?: CommandDef): Promise; interface RunMainOptions { rawArgs?: string[]; showUsage?: typeof showUsage; } declare function runMain(cmd: CommandDef, opts?: RunMainOptions): Promise; declare function createMain(cmd: CommandDef): (opts?: RunMainOptions) => Promise; declare function parseArgs(rawArgs: string[], argsDef: ArgsDef): ParsedArgs; export { type Arg, type ArgDef, type ArgType, type ArgsDef, type Awaitable, type BooleanArgDef, type CommandContext, type CommandDef, type CommandMeta, type ParsedArgs, type PositionalArgDef, type Resolvable, type RunCommandOptions, type RunMainOptions, type StringArgDef, type SubCommandsDef, type _ArgDef, createMain, defineCommand, parseArgs, renderUsage, runCommand, runMain, showUsage };