Documentation
¶
Overview ¶
Package ui is the shared terminal-UX layer: colour and TTY detection, status output, and the check table.
The primary caller of this binary is a GitHub Actions runner, not a person: the packs' scheduled workflows run it every Monday. So non-interactive behaviour is the default case rather than a degraded one -- no prompts unless stdin is a terminal, no ANSI into a log file, and a non-zero exit whenever something failed.
Index ¶
- Variables
- func ASCII() bool
- func AssumeYes() bool
- func Bold(s string) string
- func Dim(s string) string
- func Err(s string) string
- func Failure(format string, a ...any)
- func Heading(s string)
- func Info(format string, a ...any)
- func Init(c Config)
- func Interactive() bool
- func JSON(v any) error
- func JSONMode() bool
- func OK(s string) string
- func Printf(format string, a ...any)
- func Println(a ...any)
- func RenderCheckTable(rows []CheckRow) string
- func SetGlyphs(g Glyphs)
- func Status(glyph, format string, a ...any)
- func Success(format string, a ...any)
- func Summarise(results []checker.Result)
- func Table(headers []string, rows [][]string) string
- func Warn(s string) string
- func Warning(format string, a ...any)
- type CheckRow
- type Config
- type Glyphs
Constants ¶
This section is empty.
Variables ¶
var ( GlyphsUnicode = Glyphs{ Check: "✓", Cross: "✗", Warn: "⚠", Info: "ℹ", Active: "◉", Pending: "○", Paused: "⏸", Retrying: "↻", Skipped: "⊘", Cursor: "▸", Bullet: "•", Dash: "—", Ellipsis: "…", Arrow: "→", Branch: "├─", Corner: "└─", BarFull: "█", BarEmpty: "░", } GlyphsASCII = Glyphs{ Check: "[OK]", Cross: "[X]", Warn: "[!]", Info: "[i]", Active: "[..]", Pending: "[ ]", Paused: "[P]", Retrying: "[R]", Skipped: "[-]", Cursor: ">", Bullet: "*", Dash: "-", Ellipsis: "...", Arrow: "->", Branch: "|-", Corner: "`-", BarFull: "#", BarEmpty: ".", } )
GlyphsUnicode and GlyphsASCII are exported so a golden test can pin one and produce identical output regardless of the host.
var Sym = pickGlyphs()
Sym is the active glyph set.
Functions ¶
func ASCII ¶
func ASCII() bool
ASCII reports whether to fall back to ASCII glyphs.
IMT_ASCII forces the fallback and IMT_UNICODE forces Unicode; otherwise only a legacy Windows console gets ASCII. The overrides exist because the detection below is a heuristic and a user on an unusual terminal should not have to argue with it.
When both are set, ASCII wins. That is the safe direction: someone who set IMT_ASCII most likely has a terminal that renders Unicode as mojibake, and honouring the other variable there produces unreadable output, whereas the reverse merely produces plainer output than necessary.
func Init ¶
func Init(c Config)
Init configures the layer. Call once from the root command before any subcommand runs.
func RenderCheckTable ¶
RenderCheckTable renders the check results.
It lives here rather than in either front-end so the CLI and the TUI show the same five columns in the same order; drift between them would be invisible until someone compared two screenshots.
func Status ¶
Status writes a status line to stderr.
Status, progress and diagnostics go to stderr so stdout carries only the command's actual output -- which is what makes `icon-sets-sync check --json | jq` work.
func Summarise ¶
Summarise writes the one-line verdict under the check table.
It reports unresolved packs separately from stale ones. Counting only stale packs means a run in which every registry was unreachable prints "All packs up to date" -- nothing was known to be behind, because nothing was looked at. That is the false green the Python reporter shipped.
Types ¶
type CheckRow ¶
type CheckRow struct {
Package, Current, Latest, Status, Detail string
}
CheckRow is one row of the upstream-check table, front-end agnostic.
type Config ¶
type Config struct {
AssumeYes bool
NoInput bool
NoColor bool
JSON bool
Quiet bool
Out io.Writer
Err io.Writer
}
Config carries the resolved global flags.
type Glyphs ¶
type Glyphs struct {
Check, Cross, Warn, Info string
Active, Pending, Paused string
Retrying, Skipped string
Cursor, Bullet string
Dash, Ellipsis string
Arrow, Branch, Corner string
BarFull, BarEmpty string
}
Glyphs is the display symbol set, chosen once for the running terminal.
Legacy Windows consoles (bare cmd.exe, old conhost) have no Unicode font and render box-drawing and status glyphs as "?" or empty boxes. Everywhere else -- macOS, Linux, WSL, Windows Terminal, VS Code -- gets the Unicode set.
The status vocabulary is the terminal handbook's: one symbol per bucket, so a reader learns the mental model once. The ASCII column is its documented fallback set.