Documentation
¶
Overview ¶
Package ui is the CLI's presentation layer: TTY-aware color, status glyphs, aligned tables, relative timestamps, a spinner, and confirmation prompts. Everything degrades cleanly when output is not a terminal (pipes, CI) or when color is disabled via NO_COLOR / --no-color, so machine consumers get plain text and humans get a polished terminal experience.
Index ¶
- func Age(t time.Time) string
- func Bold(s string) string
- func Confirm(prompt string) bool
- func Cyan(s string) string
- func Detail(format string, a ...any)
- func Dim(s string) string
- func Fail(format string, a ...any)
- func Green(s string) string
- func Info(format string, a ...any)
- func IsTerminal() bool
- func Magenta(s string) string
- func Red(s string) string
- func SetColor(on bool)
- func Status(s string) string
- func Success(format string, a ...any)
- func Warn(format string, a ...any)
- func Yellow(s string) string
- type Spinner
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Confirm ¶
Confirm asks a yes/no question on stderr and reads the answer from stdin. A non-interactive stdin (no TTY) returns false — callers must pass --yes.
func Detail ¶
Detail prints a plain line to stdout with no leading glyph. Use it for resource-detail views (aligned "Field: value" blocks) where the arrow Info prepends would be visual noise; keep Info for progress and next-step hints.
func IsTerminal ¶
func IsTerminal() bool
IsTerminal reports whether stdout is an interactive terminal (a character device), using only the standard library.
func SetColor ¶
func SetColor(on bool)
SetColor force-enables or disables color, overriding auto-detection. The root command calls this for --no-color and structured (--json/-o) output. Color is only ever honored on a TTY, so passing true off a pipe stays plain.
Types ¶
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner is a lightweight terminal spinner for long-running waits. On a non-terminal (pipe/CI) it degrades to nothing — the caller's plain status lines carry the information instead.
func NewSpinner ¶
NewSpinner creates a spinner with an initial message (not yet started).
func (*Spinner) Start ¶
func (s *Spinner) Start()
Start begins animating on stderr. No-op off a TTY.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a minimal column-aligned table with a dimmed header row.