/** * What `npx edfcore` actually does, with the process factored out. * * Layer 7. `cli.ts` is a shell that supplies real `node:fs` and `node:process`; everything * decidable lives here, behind an injected `CliIo`. That is not ceremony — a CLI tested by * spawning a subprocess can only be tested once the package is built, so the tests either skip in * CI or test a stale binary. This way the exit codes and the output are ordinary unit tests. */ /** * A mistake in the command line, as opposed to a mistake in the file. * * The documented exit codes are 0 success, 1 the file is unreadable or failed validation, 2 bad * usage — and a script gates on them without parsing output. `parseArgs` used to throw a plain * `RangeError`, which `cli.ts` caught with everything else and reported as 1, so `--limit all` was * indistinguishable from a corrupt recording. This type is what lets the shell tell them apart. * * It EXTENDS `RangeError` rather than `Error`, so a caller who was already catching `RangeError` * from `parseArgs` — the package's convention for a caller mistake, and what the existing test * pins — keeps working unchanged. The new class narrows that, it does not replace it. */ export declare class CliUsageError extends RangeError { readonly usage: true; constructor(message: string); } /** Everything the CLI touches outside itself. */ export interface CliIo { readFile(path: string): Promise; out(text: string): void; err(text: string): void; } /** * A parsed command line, with nothing decided yet. `command` and `file` are `undefined` rather * than defaulted because a missing one is bad usage and exits 2 — supplying a default here would * turn `edfcore` alone into a silent success. */ export interface Args { readonly command: string | undefined; readonly file: string | undefined; readonly patient: boolean; readonly list: boolean; readonly version: boolean; readonly help: boolean; readonly limit: number | undefined; } /** * Turns argv into `Args`, and refuses anything it does not recognise. An unknown flag throws * `CliUsageError` rather than being ignored: a misspelled `--patinet` that silently did nothing * would print a header without the identification the caller believed they had asked for. */ export declare function parseArgs(argv: readonly string[]): Args; /** * Runs one command and RETURNS an exit code rather than setting one. Every side effect arrives * through `io`, which is what lets the CLI be driven from a test without spawning a process or * building `dist` first — `cli.ts` is the only place a real process is touched. */ export declare function runCli(args: Args, io: CliIo): Promise; //# sourceMappingURL=cli-run.d.ts.map