style

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 2 Imported by: 0

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 Bold

func Bold(s string) string

Bold wraps text that should stand out without implying success/failure.

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 Enabled

func Enabled() bool

Enabled reports the current setting.

func Error

func Error(s string) string

Error wraps text destined for a failure (red).

func Info

func Info(s string) string

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.

func Success

func Success(s string) string

Success wraps text destined for a positive/completed status (green).

func Warn

func Warn(s string) string

Warn wraps text destined for a non-fatal caution (yellow).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL