/** * Exit codes every command uses: 0 when it did what was asked, 1 when it * could not (a failed check, a failed deploy, a missing service), 2 when * the command line itself is wrong. */ export declare const EXIT: { readonly ok: 0; readonly failed: 1; readonly usage: 2; }; export type ExitCode = (typeof EXIT)[keyof typeof EXIT]; /** A failure a command reports to the user, with what to do about it. */ export declare class CommandError extends Error { readonly exitCode: ExitCode; readonly hints: string[]; constructor(message: string, options?: { hints?: string[]; exitCode?: ExitCode; cause?: unknown; }); } /** A command line that cannot work: an unknown value, a missing argument. Exits 2. */ export declare class UsageError extends CommandError { constructor(message: string, hints?: string[]); } export declare function errorMessage(error: unknown): string; /** Whether `COGITATOR_DEBUG` asks for stack traces. */ export declare function debugEnabled(env?: NodeJS.ProcessEnv): boolean; /** The exit code of any error a command ends with. */ export declare function exitCodeOf(error: unknown): ExitCode; /** * Prints how a command failed: as `{ ok: false, error }` on stdout with * `--json`, otherwise as a message with its hints on stderr, with the stack * when COGITATOR_DEBUG is set. Returns the exit code. */ export declare function reportFailure(error: unknown, options: { json: boolean; env?: NodeJS.ProcessEnv; }): ExitCode; /** The `Examples:` block of a command's help: each command with what it does. */ export declare function examplesHelp(examples: ReadonlyArray): string; /** Prints `value` as the JSON a `--json` command answers with. */ export declare function printJson(value: unknown): void; /** * Ends the process with the failure, for code that cannot throw to the * command: event handlers of child processes and signal handlers. */ export declare function exitWithFailure(error: unknown): never; //# sourceMappingURL=cli.d.ts.map