feat(cli): show ZERO wordmark on --version#673
Conversation
The TUI's empty-state ZERO ascii art gets exposed via a new tui.Wordmark helper and printed above the version line for `zero -v`/`--version`. Coloring only applies when stdout is a real TTY and NO_COLOR isn't set, so redirected or piped output (scripts parsing the version) stays plain.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThe CLI now detects whether stdout is a terminal, displaying a wordmark banner interactively while preserving ChangesTTY-aware version output
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Run
participant stdoutIsTerminal
participant tui.Wordmark
participant stdout
Run->>stdoutIsTerminal: Check stdout terminal status
stdoutIsTerminal-->>Run: Return terminal or non-terminal status
Run->>tui.Wordmark: Build wordmark for terminal output
tui.Wordmark-->>Run: Return plain ASCII wordmark
Run->>stdout: Write banner or zero version line
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The release smoke check compared zero --version output to an exact "zero <version>" string, which broke once --version started printing the wordmark above the version line. Check for a "version: <version>" suffix instead so the smoke check doesn't couple to the wordmark art.
jatmn
left a comment
There was a problem hiding this comment.
I found issues that need to be addressed before this is ready.
Findings
-
[P1] Preserve the machine-readable non-TTY version contract
internal/cli/app.go:342
Wordmarkremoves ANSI escapes for a pipe or redirection, but it still emits six banner lines and replaces the solezero <version>record withversion: <version>. That breaks existing command substitutions and exact parsers even though the PR says redirected output remains suitable for scripts; in particular, the checked-in NPM wrapper smoke contract still requireszero --versionto reportzero <package.json version>. Keep the existing single-line output when stdout is not a terminal (or provide a separately opt-in banner) and add coverage for the piped/redirection path. -
[P2] Respect selected light themes when coloring the version wordmark
internal/tui/startup.go:149
The new command bypassesnewModel, which is the only path that resolves--theme/ZERO_THEMEand applies the selected palette. As a result,zero --theme light --versionandZERO_THEME=light zero --versionrender with the global dark palette (ink #ececee), not the selected light palette (ink #22201a); on a light terminal the banner is therefore largely unreadable. Resolve and apply the requested palette for this non-TUI renderer, or render it without color outside the TUI.
…color - When stdout is not a terminal, --version prints exactly "zero <version>" again: pipes, redirects, command substitutions, and the release smoke contract all parse that single record, so the banner is a TTY-only affordance now. - The TTY path keeps the banner but restores "zero <version>" as the version record instead of "version: <version>". - Wordmark renders uncolored: only newModel resolves --theme/ZERO_THEME, so painting the global dark palette here was unreadable on light terminals. The terminal's default foreground works on any background. - smokeVersion goes back to requiring the exact "zero <version>" output instead of the suffix match that papered over the banner.
|
Pushed 1cdd3d0 for both findings.
go build, go vet, and go test on internal/cli, internal/tui, and internal/release pass locally, except TestAltScreenTranscriptScrollKeepsFooterFixed in internal/tui, which also fails on this branch without these changes and is unrelated. |
There was a problem hiding this comment.
Nice touch the TTY/pipe split is exactly right: scripts, redirects, and the NPM wrapper keep the single zero <version> record, and the wordmark only renders on an interactive terminal. I like that Wordmark() reuses the existing art and stays uncolored, so it can't go unreadable on a light theme. Build and the new tests pass in an isolated worktree; the only red tests reproduce on clean main (sandbox/add-dir), so nothing here to block on.
Summary
tui.Wordmarkhelper and prints it above the version line forzero -v/--version, as an easter egg.NO_COLORisn't set, so redirected or piped output (e.g. scripts parsing the version) stays plain text.zero <version>toversion: <version>to read correctly under the wordmark.Test plan
go build ./...go test ./internal/cli/... ./internal/tui/...zero --versionshows colored wordmark in a TTY, plain text when redirected to a file, and stays plain withNO_COLOR=1set even in a TTYSummary by CodeRabbit
New Features
Bug Fixes
zero <version>format when version output is redirected or piped.