Documentation
¶
Overview ¶
Package ui is notenv's hand-rolled terminal UI: ANSI styling, prompts, an arrow-key select, and a spinner. Built on x/term raw mode, which is already a dependency, so it adds zero new supply-chain surface.
Styling honors NO_COLOR and TERM=dumb and disables itself off-TTY. All human-facing output goes to stderr; stdout stays reserved for data.
Index ¶
- Variables
- func Bold(s string) string
- func Confirm(label string, def bool) (bool, error)
- func Cyan(s string) string
- func Dim(s string) string
- func Failf(format string, a ...any)
- func Green(s string) string
- func Heading(format string, a ...any)
- func Infof(format string, a ...any)
- func Input(label, def string) (string, error)
- func Interactive() bool
- func Notef(format string, a ...any)
- func Plainf(format string, a ...any)
- func Red(s string) string
- func Rule()
- func Select(label string, options []Option) (int, error)
- func Spin(label string, fn func() error) error
- func SpinSub(label string, fn func() error) error
- func Substep(format string, a ...any)
- func Successf(format string, a ...any)
- func Warnf(format string, a ...any)
- func Yellow(s string) string
- type Option
Constants ¶
This section is empty.
Variables ¶
var ErrCanceled = errors.New("canceled")
ErrCanceled is returned when the user aborts a prompt (Esc, q, Ctrl-C).
Functions ¶
func Heading ¶ added in v0.21.1
Heading prints a blank line then a bold section title, opening a phase.
func Plainf ¶ added in v0.21.1
Plainf prints one unadorned line to stderr (no glyph), for the body of a summary block where the status vocabulary would only add noise.
func Rule ¶ added in v0.21.1
func Rule()
Rule prints a dim horizontal rule, used to delimit a summary block.
func Select ¶
Select renders an arrow-key picker on the controlling terminal and returns the chosen index. Keys: up/down (or k/j), Enter to choose, Esc/q/Ctrl-C to cancel (returns ErrCanceled). Without a usable raw-mode terminal it falls back to a numbered prompt.
func Spin ¶
Spin runs fn while animating a spinner on stderr, then reports the outcome as a success or failure status line. Off-TTY it degrades to plain lines.
func SpinSub ¶ added in v0.21.1
SpinSub is Spin rendered as a sub-step of a phase: dim and indented while running, and it leaves a dim Substep line on success instead of a top-level status, so a phase's individual steps stay subordinate to its Heading. A failure still surfaces at full weight.