ui

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2026 License: MIT Imports: 4 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func AutoEnable(w io.Writer)

AutoEnable inspects environment + writer TTY status and sets Enabled accordingly. Precedence:

  1. NO_COLOR (any non-empty value) — disabled.
  2. JOBFORGE_COLOR=always — enabled.
  3. JOBFORGE_COLOR=never — disabled.
  4. 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(w io.Writer, title, subtitle string)

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

func CmdLine(w io.Writer, cmd, desc string)

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 Err

func Err(w io.Writer, msg string)
func Header(w io.Writer, title string)

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

func Hint(w io.Writer, msg string)

Hint prints a tip-style line. The message body is muted so hints don't fight headers and KV pairs for attention.

func Info

func Info(w io.Writer, msg string)

func KV

func KV(w io.Writer, k, v string)

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 Ok

func Ok(w io.Writer, msg string)

func SetEnabled

func SetEnabled(v bool) bool

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.

func Step

func Step(w io.Writer, msg string)

func Swatches

func Swatches(w io.Writer)

Swatches prints one colored block per named palette entry. Used by the demo so users can confirm their terminal renders the full 256-color palette correctly.

func Warn

func Warn(w io.Writer, msg string)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL