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 ColorScheme(ld lipgloss.LightDarkFunc, a Accent) fang.ColorScheme
- 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 HuhTheme(a Accent) huh.ThemeFunc
- 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 Accent
- type Mode
- type Palette
- type Result
- type Spinner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColorScheme ¶ added in v0.8.0
func ColorScheme(ld lipgloss.LightDarkFunc, a Accent) fang.ColorScheme
ColorScheme builds a fang.ColorScheme from the shared palette plus a tool's accent (a zero Accent uses DefaultAccent). Apps pass this (via cli.Run) so the slot mapping lives once in forge, not duplicated per tool.
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 HuhTheme ¶ added in v0.8.0
HuhTheme builds a huh form theme branded with the shared palette plus a tool's accent (a zero Accent uses the Ember default), so interactive prompts match the tool's fang theme. Pass it to form.WithTheme. It starts from huh.ThemeBase and overrides the focused state + errors. See forge ADR-0010.
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 Accent ¶ added in v0.8.0
type Accent struct {
Light, Dark color.Color // primary
SecondaryLight, SecondaryDark color.Color // secondary
}
Accent is a tool's brand colors over the shared palette — the primary accent (titles, program name, flags) and the secondary (subcommands), each as a light/dark pair. It is the only per-tool part of the theme; everything else comes from the palette. See forge ADR-0010.
func DefaultAccent ¶ added in v0.8.0
func DefaultAccent() Accent
DefaultAccent is forge's brand — "Ember", the forge fire (orange over coal-red). A tool that passes a zero Accent gets this; tools normally override it with their own.
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 Palette ¶ added in v0.7.0
type Palette struct {
Text color.Color // primary text
Muted color.Color // descriptions, help, comments
Dim color.Color // flag defaults, dimmed arguments
Argument color.Color // command arguments
Success color.Color // ✓ and quoted strings
Warn color.Color // !
Error color.Color // ✗ and error details
}
Palette is the family's shared structural colors — everything in a tool's theme except its per-tool accent. Resolve it with NewPalette, then an app builds its fang.ColorScheme from these plus its accent (see docs/adr/0008-ui-theme-palette.md). Semantic colors match the status helpers, so status output and the fang theme agree.
func NewPalette ¶ added in v0.7.0
func NewPalette(ld lipgloss.LightDarkFunc) Palette
NewPalette resolves the shared palette for the terminal background. Neutrals adapt to light/dark; the semantic colors are fixed (they read on both backgrounds and match status.go).
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.