Documentation
¶
Overview ¶
Package ui provides shared terminal output helpers for the adaouat CLIs: color/TTY detection, status lines, and version/help banner renderers.
Index ¶
- func Err(w io.Writer, msg string) string
- func HasColor(w io.Writer) bool
- func Header(w io.Writer, title string)
- func HelpLong(art, catchPhrase string) string
- func Info(w io.Writer, msg string) string
- func IsTTY(w io.Writer) bool
- func Skip(detail string) error
- func Success(w io.Writer, msg string) string
- func VersionTemplate(art, catchPhrase string) string
- func Warn(w io.Writer, msg string) string
- type Mode
- type Result
- type Spinner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasColor ¶
HasColor reports whether w supports ANSI color output. It delegates to colorprofile.Detect, which honours NO_COLOR, CLICOLOR_FORCE, TERM=dumb, and whether w is a terminal.
func HelpLong ¶
HelpLong returns ASCII art followed by a catch-phrase, for use as cobra root.Long. Apps pass their own art and tagline.
func Info ¶
Info returns " <msg>" dimmed when w supports color, plain otherwise. Use for hints and supplementary context below a primary status line.
func Skip ¶
Skip marks a task as advisory: Spinner.Run renders "! name — detail" instead of success or failure and returns nil.
func VersionTemplate ¶
VersionTemplate returns a cobra text/template string for --version output. cobra fills {{.Name}} and {{.Version}} at runtime.
Types ¶
type Mode ¶
type Mode int
Mode is a CLI's output mode. Spinners, progress bars, and colors are only shown in Human mode on a real TTY. The zero value is Human.
type Result ¶
Result is a task's successful outcome: a Detail shown after the task name ("✓ name — Detail") and optional indented sub-result lines.
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner runs named tasks, animating a spinner while each runs (human mode on a TTY) and resolving it to a ✓/✗/! status line written to out.
func NewSpinner ¶
NewSpinner constructs a Spinner writing to out, animating only in m's human mode.