Documentation
¶
Overview ¶
Package ui centralizes terminal feedback for the CLI: TTY/color detection, status lines, confirmation prompts, and spinners. Following CLI conventions, human-facing status goes to stderr and is gated on a real terminal; machine output (--json etc.) is the command's own responsibility on stdout.
Index ¶
- func AssumeYes() bool
- func ColorEnabled() bool
- func Confirm(prompt string, def bool) bool
- func Fail(format string, a ...any)
- func Info(format string, a ...any)
- func IsTTY() bool
- func SetAssumeYes(v bool)
- func SetNoColor(v bool)
- func SetNoInput(v bool)
- func Spin(title string, fn func() error) error
- func Success(format string, a ...any)
- func Warn(format string, a ...any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssumeYes ¶
func AssumeYes() bool
AssumeYes reports whether `--yes` was set (for callers that branch on it).
func ColorEnabled ¶
func ColorEnabled() bool
ColorEnabled reports whether colored output should be produced. It honors `--no-color`, the NO_COLOR convention, TERM=dumb, and non-TTY stdout.
func Confirm ¶
Confirm asks a yes/no question with a safe default. It returns true on `--yes`, the default when `--no-input` or stdin is not a terminal, and otherwise prompts (EOF/blank → default). The prompt and answer flow use stderr/stdin so stdout stays clean for machine output.
func SetAssumeYes ¶
func SetAssumeYes(v bool)
SetAssumeYes makes Confirm always return true (the `--yes` flag).
func SetNoInput ¶
func SetNoInput(v bool)
SetNoInput makes Confirm never prompt and return the default (`--no-input`).
func Spin ¶
Spin runs fn while showing a spinner (on a TTY) or a plain "…" line (otherwise). It returns fn's error; callers report success/failure themselves.
Types ¶
This section is empty.