Skip to content

Migrate hardcoded ANSI color codes to fatih/color#158

Merged
mroth merged 2 commits intomainfrom
mroth/migrate-fatih-color
Apr 20, 2026
Merged

Migrate hardcoded ANSI color codes to fatih/color#158
mroth merged 2 commits intomainfrom
mroth/migrate-fatih-color

Conversation

@mroth
Copy link
Copy Markdown
Owner

@mroth mroth commented Apr 8, 2026

Summary

  • Replace custom Color string type and raw ANSI escape sequences with fatih/color for cross-platform terminal support
  • Detect color support via stderr TTY (since stdout is always a pipe in the scmpuff_status shell wrapper) and honor the NO_COLOR convention
  • Windows console compatibility via go-colorable
  • Add display.plain golden file tests and integration tests for color detection

Closes #28

Test plan

  • All existing tests pass (go test ./...)
  • ANSI golden files updated — diff reviewed for visual equivalence (only escape code formatting changes, no semantic color differences)
  • New plain-text golden files validate the color.NoColor = true path
  • Integration test: NO_COLOR=1 disables color through scmpuff_status shell wrapper (bash/zsh/fish)
  • Integration test: non-TTY stderr disables color through scmpuff_status shell wrapper (bash/zsh/fish)
  • Manual visual inspection of scmpuff status matching prior appearance

mroth and others added 2 commits April 8, 2026 09:58
Replace custom Color type and raw ANSI escape sequences with
fatih/color for cross-platform terminal support. This enables
automatic NO_COLOR env var support, TERM=dumb detection, and
Windows console compatibility via go-colorable.

Add display.plain golden file tests to verify color-disabled output.

Closes #28

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The status command is typically invoked via the scmpuff_status() shell
wrapper which captures stdout in a subshell, so fatih/color's default
TTY detection (against stdout) always sees a pipe. Instead, check
stderr (which remains connected to the user's terminal) and honor
the NO_COLOR convention (https://no-color.org/).

Add integration test verifying both NO_COLOR and non-TTY detection
through the full shell wrapper across bash/zsh/fish.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mroth
Copy link
Copy Markdown
Owner Author

mroth commented Apr 8, 2026

@christoph-heiss want to take a look at these new ANSI files and make sure they still work on your terminal theme?

@mroth
Copy link
Copy Markdown
Owner Author

mroth commented Apr 20, 2026

Have been running locally for 2 weeks and working fine for me, so going to mark visual inspection manually verified.

@mroth mroth merged commit c92e609 into main Apr 20, 2026
19 checks passed
@mroth mroth deleted the mroth/migrate-fatih-color branch April 20, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scmpuff status: migrate hardcoded ANSI color codes to a cross-platform color library

1 participant