Documentation
¶
Overview ¶
Package ui provides small terminal output helpers with an optional baby-blue color theme. The package is stdlib-only.
Color output is OFF by default so unit tests that capture output into a bytes.Buffer see the exact same plain bytes the package has always emitted. Real binaries flip it on at startup via AutoEnable, which checks NO_COLOR, JOBFORGE_COLOR, and whether the writer is an interactive terminal.
Index ¶
- Variables
- func AutoEnable(w io.Writer)
- func Banner(w io.Writer, title, subtitle string)
- func CmdLine(w io.Writer, cmd, desc string)
- func Err(w io.Writer, msg string)
- func Header(w io.Writer, title string)
- func Hint(w io.Writer, msg string)
- func Info(w io.Writer, msg string)
- func KV(w io.Writer, k, v string)
- func Ok(w io.Writer, msg string)
- func SetEnabled(v bool) bool
- func Step(w io.Writer, msg string)
- func Swatches(w io.Writer)
- func Warn(w io.Writer, msg string)
Constants ¶
This section is empty.
Variables ¶
var Enabled = false
Enabled controls whether color/Unicode glyphs are emitted. Tests should leave this false; main.AutoEnable flips it on for real terminals.
Functions ¶
func AutoEnable ¶
AutoEnable inspects environment + writer TTY status and sets Enabled accordingly. Precedence:
- NO_COLOR (any non-empty value) — disabled.
- JOBFORGE_COLOR=always — enabled.
- JOBFORGE_COLOR=never — disabled.
- Otherwise: enabled iff w is a *os.File backed by a terminal.
On Windows we also best-effort enable ENABLE_VIRTUAL_TERMINAL_PROCESSING so ANSI codes render in conhost; if that fails we still emit codes (modern Windows builds parse them by default since 1809).
func Banner ¶
Banner prints a hero block for the demo and (optionally) startup. Two colored rules wrap a bold title and a muted subtitle. When Enabled is off we still produce a recognizable plain banner, so `jobforge ui demo` is useful when piped to a file too.
func CmdLine ¶
CmdLine prints a command/description pair with a wider alignment than KV, suited for the slash command palette where labels run to ~28 characters (e.g. "/jobs import --source <id>"). Color treatment mirrors KV.
func Header ¶
Header prints a divider above and below the title. The title is always on its own line as " Title\n"; downstream tests rely on that exact substring (see TestApplyEditDraftSourceMarkedHumanEdited which counts "Draft\n").
When Enabled, we use Unicode box-drawing rules and a colored title; when disabled, we keep ASCII "=" so plain output remains byte-identical to the pre-color implementation.
func Hint ¶
Hint prints a tip-style line. The message body is muted so hints don't fight headers and KV pairs for attention.
func KV ¶
KV prints a label/value pair with consistent alignment. Pad width matches the legacy implementation (14) so existing list/show layouts don't shift.
func SetEnabled ¶
SetEnabled is a tiny setter so callers don't read/write the package var directly. Returns the previous value so tests can save and restore.
Types ¶
This section is empty.