Route all CLI output through the command's stdout/stderr - #186
Merged
Conversation
Askir
approved these changes
Aug 10, 2026
Askir
left a comment
Contributor
There was a problem hiding this comment.
I think CI/CD is red due to a flake. Looks good to me though!
The example still showed the fmt.Fprintf(cmd.ErrOrStderr(), ...) form this branch replaced everywhere else.
nathanjcochran
force-pushed
the
nathan/improve-output
branch
from
August 11, 2026 15:46
95a1f12 to
73eafe5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adopts Ghost's output conventions. Commands now print with cobra's
cmd.Print*/cmd.PrintErr*helpers instead offmt.Print*or spelled-outfmt.Fprintf(cmd.OutOrStdout(), …), and the root command wires its writers to stdout/stderr explicitly — cobra'sPrint*silently falls back to stderr otherwise (which is whytiger upgradewas sending all its progress to the wrong stream). Helpers insideinternal/cmdtake the command and print through it; code ininternal/commonandinternal/versionstill takes anio.Writerso it stays free of cobra.The payoff is that every byte a command emits now flows through writers we control, so stream choice is auditable and all output is capturable in tests (I intend to refactor our testing patterns in a later PR, and this helps set the stage for it). Additionally, using the
cmd.Print*helpers is just cleaner, less verbose, and easier to read overall (imo). Finally, thecmd.Print*helpers do not return an error (unlikefmt.Fprint*), which is helpful in case we ever want to add errcheck to the CI pipeline (but we're still a long way from that, currently 😅).This PR also codifies the rule for what goes where: stdout carries the actual command result/payload, whereas stderr carries warnings, progress updates, and anything interactive. Anything that previously did not adhere to that rule has been updated.
Bug fixes and behavior changes that came out of it:
tiger mcp install's success banner andtiger auth login's credential prompts were writing straight to the process's stdout, bypassing the command entirely and therefore invisible to tests.tiger db test-connectionprinted its own diagnostic and then let cobra print the raw error a second time, plus the full usage block. It now reports once.tiger upgrade's progress output moves from stderr to stdout.auth loginanddb save-passwordmove to stderr, so they stay visible when stdout is redirected.auth loginOAuth flow — auth URL, browser warnings, and the project picker — moves to stderr. Redirecting stdout previously hid the picker entirely while it sat waiting for keystrokes.The conventions are written up in CLAUDE.md.