Repository navigation
feat: write hand-written command messages to stderr - #355
Conversation
Add lib/ui/log.ts with clack log lines on stderr, the ✓ success line and copyable command lines. formatOutput now prints its success line through the shared helper, and the account hint reuses the guide width. Add mockOutputStreams, which captures console calls and direct stream writes per stream so tests can assert that stdout holds only output.
cf auth login/logout, the auth profile commands, cf cli telemetry enable/disable and cf migrate printed notices, warnings and results on stdout. They now go to stderr as clack log lines and ✓ success lines, so redirected stdout holds only command output, as with generated commands. A command to run next is printed on its own line, and cf auth login with CLOUDFLARE_API_TOKEN set prints a single warning. Refs cloudflare#53
With CLOUDFLARE_API_TOKEN set, login printed messages about stored or expired OAuth tokens before refusing. Warn about the token first.
printSuccess moves to lib/output.ts so commands that only print a success line do not load @clack/prompts. mockOutputStreams treats stderr as a non-terminal unless a test opts in, and cf auth create gains a test.
|
Hi @khoinguyenpham04. Thanks for contributing to During the open beta, we’re being very intentional about the changes we accept so that we can prioritise stability for GA. We’re limiting pull requests to contributions coordinated with the team in advance, so this PR has been automatically closed. We’d still love to hear about your use case, so please make sure it’s captured in a |
|
💬 Approved with comments — The move from stdout to stderr is consistent across the commands this pull request covers, and the tests now assert that stdout stays empty. There are two non-blocking INFO notes: a silent Findings: 2 info The decision is advisory: this comment never approves, blocks or requests changes on the pull request. 🔧 Fix with your agentPaste the following into your coding agent to investigate and fix these issues. 📋 Code Quality: 💬 2 infoThe stdout-to-stderr move is applied consistently. Two minor notes: a silent branch in Recommendation: 💬 Optional Nits
View full review
Other points checked:
✅ All other checks passed🚀 Release: ✅ LGTMThe changeset is present for this user-facing output change. Risk: low. 🔒 Security: ✅ LGTMThe change moves output from stdout to stderr. The new 📖 AGENTS.md: ✅ LGTMThe AGENTS.md edits document the new stderr output convention and update the ⚡ Performance: ✅ LGTMThe new 📝 Documentation: ✅ LGTMThe changeset and the AGENTS.md updates match the new behaviour. Reviewed commit: |
|
clanky review |
commit: |
|
clanky review |
|
clanky review |
1 similar comment
|
clanky review |
|
clanker review |
dario-piotrowicz
left a comment
There was a problem hiding this comment.
In all the tests that are removing some assertion for stdout shouldn't corresponding assertions for stderr be added? (sorry I did comment this in a couple of places before thinking of commenting it here 🙈)
# Conflicts: # packages/cli/src/commands/auth/login.ts
Part of #53 (proposal).
Hand-written commands printed notices and results on stdout, so
cf auth logout > out.txtwrote "You are not currently logged in" into the file. They now use stderr, like generated commands.cf auth login/logout, the auth profile commands,cf cli telemetry enable/disable,cf migrateand thecf loginnotice.✓success line. A next step goes on its own line, so it copies cleanly.cf auth loginwithCLOUDFLARE_API_TOKENset prints one warning instead of two.mockOutputStreamstest helper. Tests check that stdout stays empty.Not in this PR: prompts and spinners, and the init/build/deploy flows.