[terminal-stylist] Terminal Stylist: Console Output Analysis (Lipgloss/Huh) #55050
Closed
Replies: 1 comment
|
This discussion was automatically closed because it expired on 2026-08-24T08:53:41.741Z.
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Terminal Stylist Report — Console Output Analysis
Scope: 8 non-test
.gofiles usingfmt.Print*; codebase-wide scan forlipgloss/huhpatterns inpkg/.Summary
The codebase has a mature, centralized styling infrastructure in
pkg/consoleandpkg/styles, and console output is largely consistent. Findings below are minor polish opportunities, not systemic problems.✅ What's Working Well
pkg/styles/theme.go,pkg/styles/huh_theme.go): adaptive light/dark colors vialipgloss.AdaptiveColor, well-documented semantic palette (Error/Warning/Success/Info).pkg/console/console.gogates all styling throughapplyStyle/applyStdoutStyleWithTTY, downgrading ANSI viacolorwriter.Degradeand honoringNO_COLOR/COLORTERM/TERM. No unguarded raw ANSI escapes found outsidepkg/console/terminal.go(cursor/clear-line control codes, which are appropriately low-level) andpkg/stringutil/ansi.go(an ANSI-stripping utility).pkg/console/print.goexposesPrintSuccessMessage,PrintInfoMessage,PrintWarningMessage,PrintErrorMessage,PrintCommandMessage,PrintSectionHeader— a clean, uniform API used throughoutpkg/cli.pkg/styles/theme.go— all consumers use semantic style constants (e.g.,styles.Error,styles.ColorInfo), which is exactly right.lipgloss/v2/tableinpkg/console/console.goonly — no ad-hoc manual table formatting found elsewhere.pkg/console/accessibility.go(IsAccessibleMode) checksACCESSIBLE,TERM=dumb, andNO_COLOR, and is wired intohuh.FormviaWithAccessible(IsAccessibleMode())inpkg/console/prompt_form.go— forms degrade gracefully for screen readers/non-interactive terminals.NewForm,NewInputForm,NewSelectForm,NewConfirmForminpkg/console/prompt_form.go), each auto-applyingstyles.HuhThemeand accessibility — a good pattern preventing inconsistent ad-hochuh.NewForm(...)calls. Confirmed consumers (pkg/cli/run_interactive.go,add_interactive_*.go,bootstrap_profile_*.go,interactive.go,engine_secrets.go) rely on these wrappers rather than rawhuhcalls.IsUserAbortedError(wrapshuh.ErrUserAborted), avoiding duplicated error-string checks across interactive flows.🔍 Minor Observations (fmt.Print usage)
Two non-test files use
fmt.Printdirectly instead offmt.Fprint*(os.Stdout, ...)/console helpers:pkg/cli/status_command.go:295—fmt.Print(console.RenderStruct(statuses))Already delegates styling to
console.RenderStruct; only the print call itself is raw. Low-risk, but for consistency with the surrounding code in the same function (which usesfmt.Fprintln(os.Stdout, ...)andfmt.Fprintln(os.Stderr, ...)a few lines above), considerfmt.Fprint(os.Stdout, console.RenderStruct(statuses))for uniform stream targeting.pkg/cli/view_command.go:168—fmt.Print(output)whereoutput := renderUnifiedTimelineStream(events).Same pattern: styled content already built via console helpers; only the final print bypasses explicit
os.Stdouttargeting. Same minor suggestion applies.All other
fmt.Print*matches are in linter test fixtures (testdata/) or doc comments — not applicable.Recommendations
status_command.go:295,view_command.go:168fmt.Printtofmt.Fprint(os.Stdout, ...)for explicit stream targeting, matching sibling calls in the same functions. Purely stylistic — current behavior is correct since both already target stdout by default.NewForm/NewInputForm/etc.) is a best practice — continue routing all new interactive prompts throughpkg/console/prompt_form.gorather than callinghuh.NewFormdirectly, to keep theme + accessibility guarantees automatic.Conclusion
No significant anti-patterns found. The
pkg/console+pkg/styleslayering is a strong foundation that new code already follows. Only two trivialfmt.Print→fmt.Fprint(os.Stdout, ...)cleanups are suggested for full consistency; neither affects behavior or accessibility.All reactions