Skip to content

Commit 3e1ca76

Browse files
crowlbotclaude
authored andcommitted
feat: add --json, --non-interactive flags and exit-code taxonomy
Make the CLI usable by AI agents and CI bots: - Global `--json` flag emits a single JSON object/array on stdout and a structured `{ error: { code, message, hint, traceId } }` envelope on stderr. Suppresses spinners, progress bars, and ANSI color so output pipes cleanly into `jq`. Wired into `publish` (final result with revisionId, URL, status, timelines) and `create` (including `--dry-run`, which now emits the resolved build config as JSON). - Global `-y, --non-interactive, --yes` flag makes `requireInteractive()` fail fast with a clear `NON_INTERACTIVE_REQUIRED` error instead of hanging on stdin, even on a TTY. Same flag on both `deploy` and `sandbox` roots. - `ExitCode` enum (OK=0, GENERIC=1, USAGE=2, AUTH=3, NOT_FOUND=4, CONFLICT=5, NETWORK=6). `error()` accepts `{ code, errorCode, hint, response }` and exits with the matching numeric code. tRPC errors are mapped via `mapTrpcError()`: 401/403/NOT_AUTHENTICATED/TOKEN_EXPIRED → AUTH, 404 → NOT_FOUND, 409 → CONFLICT, 5xx → NETWORK. Invalid-token path emits `AUTH_INVALID_TOKEN` with an explicit hint pointing at `DENO_DEPLOY_TOKEN` rather than retrying through a browser. - Move the keychain-unavailable warning from stdout to stderr so it doesn't pollute machine-readable output. Adds `tests/agent.test.ts` covering JSON dry-run, non-interactive short-circuit, `AUTH_INVALID_TOKEN` envelope, and the `-y` alias. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 73b65b9 commit 3e1ca76

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

main.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ export type GlobalContext = {
3333
if (Deno.env.has("DENO_DEPLOY_CLI_SANDBOX")) {
3434
await sandboxCommand.parse(Deno.args);
3535
} else {
36-
await deployCommand.command("sandbox", sandboxCommand).parse(Deno.args);
36+
// Cliffy's accumulated generic chain (parent options × subcommand contexts)
37+
// overflows the inference budget when stacking root commands with several
38+
// globalOptions. The cast is type-only; runtime is unaffected.
39+
// deno-lint-ignore no-explicit-any
40+
await deployCommand.command("sandbox", sandboxCommand as Command<any>).parse(
41+
Deno.args,
42+
);
3743
}
3844

3945
export function createSwitchCommand(

0 commit comments

Comments
 (0)