Add ColorScheme to Term - #280
Open
heaths wants to merge 1 commit into
Open
Conversation
Resolves cli#279
This was referenced Aug 13, 2026
Contributor
There was a problem hiding this comment.
Copilot review overview
Review tier: Lite
Findings: 1
New issues introduced by this change (3)
| Severity | Finding |
|---|---|
pkg/term/color.go — In ColorScheme, the field name Is256Enabled is inconsistent with the existing… |
|
pkg/term/color_test.go — This test case is currently exercising the inaccessible gray-path because Accessible defaults… |
|
pkg/term/env.go — PR description says this “Resolves #279”, but the new Term.ColorScheme() API is not yet used… |
What changed in this PR
Adds a ColorScheme API to pkg/term so callers can derive consistent ANSI styling behavior (including accessibility and theme awareness) from the current terminal environment.
Changes:
- Introduces
term.ColorSchemewith common color/style helpers (muted, highlight, icons, reset). - Adds
Term.ColorScheme()plus exported theme constants (NoTheme,LightTheme,DarkTheme). - Adds unit tests covering the new
ColorSchemebehaviors.
| File | Description |
|---|---|
| pkg/term/env.go | Adds exported theme constants and a Term.ColorScheme() constructor that threads through theme, accessibility, and color capability flags. |
| pkg/term/color.go | Introduces the new ColorScheme type and its ANSI styling helpers. |
| pkg/term/color_test.go | Adds tests validating ColorScheme output behavior across themes and capabilities. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| want string | ||
| }{ | ||
| {name: "disabled returns plain text", cs: ColorScheme{ColorEnabled: false}, want: "plain"}, | ||
| {name: "default theme no color", cs: ColorScheme{ColorEnabled: true, Theme: NoTheme}, want: "plain"}, |
Comment on lines
+157
to
+161
| // ColorScheme returns the [ColorScheme] for the current Term. | ||
| func (t Term) ColorScheme() ColorScheme { | ||
| return ColorScheme{ | ||
| Accessible: color.IsAccessibleColorsEnabled(), | ||
| ColorEnabled: t.colorEnabled, |
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.


Resolves #279