/** * Argv construction and command re-dispatch (interactive-cli-menu/AC-22, * interactive-cli-menu/AC-23, interactive-cli-menu/AC-24, * interactive-cli-menu/AC-25, interactive-cli-menu/AC-36, * interactive-cli-menu/AC-37). * * A selected entry runs through commander's own parser, so there is exactly one * code path per command and every option default, coercion, and validation still * applies. No command's logic is reimplemented here. * * @module */ import type { Command } from 'commander'; import { CommanderError } from 'commander'; import type { MenuEntry } from './roster.js'; /** Every command in a tree, root first. */ export declare function allCommands(cmd: Command): Command[]; /** * Build the argv for a selected entry (interactive-cli-menu/AC-37). * * Prompted values go after a `--` separator so commander can never parse one as * an option: without it, a user typing `--json` at a term prompt produces * `error: unknown option`, and one typing `--help` gets help printed with exit 0 * — a silent success that ran nothing. With it, both arrive as literal values. * * The `['node','aidlc']` prefix matches commander's default `from: 'node'`, * which treats argv[0]/argv[1] as the exec path and script and parses from * index 2. No separator is emitted when there are no values. */ export declare function buildArgv(entry: MenuEntry, values?: readonly string[]): string[]; export interface RunOutcome { /** The command's action ran to completion. */ ran: boolean; /** Set when commander threw instead of dispatching. */ commanderError?: CommanderError; /** * Commander wrote help or version output and "failed" with exit code 0. * Not an error — the user got what they asked for. */ displayedHelp?: boolean; } /** * Re-dispatch a synthesized argv through a commander program * (interactive-cli-menu/AC-22, interactive-cli-menu/AC-36). * * A **fresh** program is built for the dispatch rather than reusing the caller's. * `exitOverride()` has no public un-set, and commander copies inherited settings * into a subcommand at *creation* time — so overriding a shared program means * either leaving it permanently mutated (a later parse would throw where it used * to exit) or reaching for the private `_exitCallback` to restore it. A * throwaway program avoids both, and re-registers through the same `registerX` * functions, so it is the same code path per command. * * The recursion is mandatory: applied to the root alone *after* the subcommands * exist, `exitOverride` is a no-op for every one of them and the process exits * from inside the nested parse. */ export declare function runEntry(makeProgram: () => Command, argv: readonly string[]): Promise; //# sourceMappingURL=dispatch.d.ts.map