Documentation
¶
Overview ¶
Package term styles the bide command's text output for a terminal: a check mark and green for what passed, a cross and red for what failed, amber for a warning or a gate, bold cyan for a path or address to act on, dim for secondary detail. Status is never carried by color alone: a styled line keeps its words, and adds a mark (✓ or ✗) beside them.
Color is on for a terminal only (an *os.File that is a character device), and off when NO_COLOR is set to anything or TERM is dumb. On Windows it is on only where the terminal is known to read ANSI escapes (Windows Terminal, ConEmu, ANSICON, VS Code, or a TERM such as xterm-256color). A -color=always or -color=never flag overrides all of that. Output to a file or a pipe is plain, so a script or CI log reads the same text it always did.
The package is the standard library only, so bide audit's build stays core-only.
Index ¶
- Constants
- Variables
- type Mode
- type Style
- func (s Style) Bang() string
- func (s Style) Blue(t string) string
- func (s Style) Bold(t string) string
- func (s Style) BoldFail(t string) string
- func (s Style) BoldOK(t string) string
- func (s Style) Cross() string
- func (s Style) Cyan(t string) string
- func (s Style) Dim(t string) string
- func (s Style) ErrorPrefix() string
- func (s Style) Fail(t string) string
- func (s Style) Heading(t string) string
- func (s Style) Hint(msg, sep string) string
- func (s Style) OK(t string) string
- func (s Style) On() bool
- func (s Style) Pass() string
- func (s Style) Path(t string) string
- func (s Style) Warn(t string) string
Constants ¶
const FlagUsage = "`when` to color the output: auto (the default: on a terminal, unless NO_COLOR is set or TERM is dumb), always or never"
FlagUsage is the help text of every -color flag.
Variables ¶
var IsTerminal = isTerminal
IsTerminal reports whether w is a terminal. A test of a command's terminal output replaces it, to check what NO_COLOR and TERM do on a terminal without opening one.
Functions ¶
This section is empty.
Types ¶
type Mode ¶
type Mode int
Mode is the -color flag: auto (the default), always or never.
type Style ¶
type Style struct {
// contains filtered or unexported fields
}
Style styles text, or leaves it as it is when color is off. The zero Style is off.
func (Style) Bang ¶
Bang is an amber exclamation mark and a space when color is on, and nothing when it is off.
func (Style) ErrorPrefix ¶
ErrorPrefix is a bold red "error:" and a space when color is on, and nothing when it is off: an error line on a terminal opens with it, and a piped one stays as it was.
func (Style) Hint ¶
Hint dims what follows the first sep in msg, a "what to do next" the message carries after a colon or a semicolon, and leaves msg as it is when color is off or msg has no sep. sep stays with the plain part.
func (Style) Pass ¶
Pass is a green check mark and a space when color is on, and nothing when it is off: a colored line carries a mark beside its words, a plain line stays as it was.