Documentation
¶
Overview ¶
Package style provides a handful of ANSI color helpers that stay silent (return the input unchanged) unless the CLI is confident the output is going to a terminal that renders color. Never emit raw escape codes into a pipe, a log file, or a terminal that doesn't understand them.
Enabled defaults to false and is only ever flipped on by an explicit SetEnabled call -- normally once, at startup, after resolving --color/ --no-color against Detect(). This keeps every other call site (including every existing test that invokes a command's RunE directly, bypassing cmd.Execute()'s startup hook) plain-text by default with zero risk of color codes leaking into output nobody asked to colorize.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Detect ¶
func Detect() bool
Detect reports whether stdout looks like a terminal that renders ANSI color, honoring the NO_COLOR convention (https://no-color.org -- presence of the variable disables color regardless of its value) and TERM=dumb. It does not itself enable anything; callers combine it with any --color/ --no-color override and pass the result to SetEnabled.
func Info ¶
Info wraps text that deserves emphasis without implying success, failure, or caution -- section headers, "this is in progress" verbs, and explicit dry-run/preview markers (cyan).
func SetEnabled ¶
func SetEnabled(v bool)
SetEnabled sets whether the wrap helpers below emit color escapes.
Types ¶
This section is empty.