import type { StandardSchemaV1 } from "@standard-schema/spec"; import type { Deps } from "./deps.js"; import { type AnyMiddleware, type Middleware } from "./middleware.js"; type Action = (parsed: O, ctx: C) => unknown; /** * A Standard Schema that accepts command-line strings. Use * `z.coerce.number()` for numeric arguments, for example. */ export type Arg = StandardSchemaV1; /** What a caller can say about an option or a positional beyond its schema. */ export type Meta = { /** Supplying one makes the option or argument optional. */ default?: T; /** The line the help output prints beside it. */ description?: string; }; /** * What a caller can say about a variadic argument. It has no `default`: a * variadic with nothing left to collect is an empty array, never missing. */ export type RestMeta = Pick, "description">; export declare class Command { readonly name: string; private _description; private options; private args; private variadic; private middleware; private _action; private hasAction; private unknownOptions; private excessArguments; private passThrough; constructor(name: string); description(description: string): this; summary(): string; option(name: K, schema: Arg, meta?: Meta): Command; /** * An option given any number of times, collecting each value in order as * an array. The schema describes one of them, so * `repeated("tag", z.string())` arrives as `string[]`, empty when it was * never given. */ repeated(name: K, schema: Arg, meta?: RestMeta): Command; arg(name: K, schema: Arg, meta?: Meta): Command; /** * The last positional, collecting every argument left over as an array. The * schema describes one of them, so `rest("args", z.string())` arrives as * `string[]`, empty when there was nothing left. Only one is allowed, and * nothing may be declared after it. */ rest(name: K, schema: Arg, meta?: RestMeta): Command; /** * Lets a flag this command never declared through as an ordinary argument, * for a command that forwards what it is given to another program. Declared * options are still read from the same command line. */ allowUnknownOption(allow?: boolean): this; /** Lets more arguments arrive than were declared, instead of failing. */ allowExcessArguments(allow?: boolean): this; /** * Stops reading options once the first argument has arrived, so everything * past it is an argument however it is spelled. `cmd --port 80 run` reads * `--port`; `cmd run --port 80` passes it on, with no `--` needed. */ passThroughOptions(passThrough?: boolean): this; /** * Wraps this command's action, inside whatever the `Cli` already wraps it * with. Has to come before `action`, which is typed against the context the * chain produces. */ use(middleware: Middleware): Command; action(action: Action): this; exec(argv: string[], deps: Pick & Partial>, outer?: AnyMiddleware[], path?: string): unknown; /** * Whether this run is asking for help rather than doing anything. Only what * is still being read as an option counts: past a `--`, or past the first * argument of a pass-through command, `--help` belongs to whatever this * command forwards to. */ private wantsHelp; private isValue; private isSwitch; private parse; private optionRow; private help; } export {};