Skip to content

refactor(cli): route success/status output to stderr#122

Open
tcerqueira wants to merge 3 commits into
mainfrom
tc/stderr-success-discipline
Open

refactor(cli): route success/status output to stderr#122
tcerqueira wants to merge 3 commits into
mainfrom
tc/stderr-success-discipline

Conversation

@tcerqueira

Copy link
Copy Markdown
Member

What

Generalizes the CLI's stdout-discipline convention (previously documented for --json only) to human mode too. The rule is now uniform across all commands and both modes:

  • stdout carries only data payloads — in --json the single JSON result object; in human mode the actual data a user would pipe (list/query tables, identity dumps).
  • All success / confirmation / status / empty-state messages go to stderr via console.error, in both --json and human modes.

Files in this PR (orphan files not owned by an in-flight PR)

  • deploy/create/mod.ts — "Using the following build configuration", "✔ Created app …", revision-URL info, and the post-create "go to the revision page" hint → stderr.
  • deploy/mod.tswhoami "✔ Authenticated as …" confirmation → stderr (the orgs table stays on stdout as data); logout "✔ Successfully logged out" → stderr. The logs region is untouched (sibling PR).
  • deploy/orgs.ts — "No organizations accessible with this token." empty-state → stderr (list data stays on stdout).
  • deploy/deployments.ts — "No deployments for this application." empty-state and "More results available; pass --cursor …" pagination hint → stderr (list data stays on stdout).

Covered by sibling PRs (not touched here)

config.ts (#118 — config-file-creation + "Selected org/app" messages), deploy/env.ts (#119), deploy/database.ts (#117), deploy/setup-cloud.ts (#115), main.ts/switch (#116), deploy/apps.ts + deploy/publish.ts (#121), sandbox/* (#118).

Verification

deno fmt --check, deno lint, deno check all pass. Live-checked against a throwaway org/app:

  • orgs list / deployments list (human + --json): data on stdout, stderr clean.
  • create --dry-run (human): build-config echo on stderr, stdout empty; (--json): single JSON object on stdout, stderr empty.
  • whoami (human): orgs table on stdout, "✔ Authenticated as …" on stderr; (--json): single object on stdout, stderr empty.
  • logout: confirmation on stderr.

Generalize the stdout-discipline convention to human mode: stdout carries
only data payloads (list/query tables, identity dumps), while
success/confirmation/status/empty-state messages go to stderr in both
--json and human modes.

- create: 'Using the following build configuration', 'Created app',
  revision-URL and post-create hints -> stderr
- whoami: '✔ Authenticated as …' confirmation -> stderr; orgs table stays
  on stdout as data
- logout: 'Successfully logged out' -> stderr
- orgs list: empty-state notice -> stderr
- deployments list: empty-state notice and pagination hint -> stderr
tokenStorage.remove() (reached via `logout`) printed KEYCHAIN_WARNING via
console.log, unlike its siblings in get()/set() which use console.error.
Route it to stderr so the warning never pollutes stdout.
The dry-run create tests asserted the 'Using the following build
configuration:' echo on stdout, but it now goes to stderr per the
stdout-discipline convention. Capture combined stdout+stderr in the
`deploy` test helper (matching `deployFail`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant