/** * CLI command implementation for roll-parser. * * Split out of `index.ts` so `main` and `writeErrorContext` can run * in-process under the test runner — the shebang entry point stays a thin * wrapper that owns `process.argv`, the real streams, and `process.exitCode`. * * @module cli/main */ /** Sink for one stream's worth of CLI output. */ export type WriteFn = (text: string) => void; /** Everything `main` needs from the host process. */ export type CliEnv = { /** Arguments after the interpreter and script path (`process.argv.slice(2)`). */ argv: string[]; stdout: WriteFn; stderr: WriteFn; }; /** * Prints the notation with a caret under the error position. `getErrorSpan` * normalizes the lexer/parser `position` and the evaluator `start`/`end` * shapes, so no duck-typing is needed here. Skipped for multi-line notations * and out-of-range positions to keep the caret honest. */ export declare function writeErrorContext(notation: string, error: unknown, write: WriteFn): void; /** * Runs one CLI invocation and returns the process exit code: `0` on success, * `1` for a roll-parser error, `2` for a usage error. Anything that is not a * `RollParserError` propagates so the runtime reports it with a stack. * * `--json` swaps the success payload on stdout and every diagnostic on * stderr, usage errors included. Exit codes are identical either way, so * scripts can still branch on the code before reading a stream. */ export declare function main(env: CliEnv): number; //# sourceMappingURL=main.d.ts.map