feat(06-01): add Formatter interface, Registry, and TTY color detection

- pkg/output/formatter.go: Formatter interface, Options, Registry with
  Register/Get/Names, ErrUnknownFormat sentinel
- pkg/output/colors.go: IsTTY + ColorsEnabled honoring NO_COLOR
- Promote github.com/mattn/go-isatty to direct dependency
- Unit tests cover registry round-trip, unknown lookup, sorted Names,
  non-TTY buffer, NO_COLOR override

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
salvacybersec
2026-04-05 18:41:23 +03:00
parent ce37ee2bc5
commit 291c97ed0b
5 changed files with 205 additions and 1 deletions

2
go.mod
View File

@@ -6,6 +6,7 @@ require (
github.com/atotto/clipboard v0.1.4
github.com/charmbracelet/lipgloss v1.1.0
github.com/go-git/go-git/v5 v5.17.2
github.com/mattn/go-isatty v0.0.20
github.com/panjf2000/ants/v2 v2.12.0
github.com/petar-dambovaliev/aho-corasick v0.0.0-20250424160509-463d218d4745
github.com/spf13/cobra v1.10.2
@@ -43,7 +44,6 @@ require (
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/ncruces/go-strftime v1.0.0 // indirect