Documentation
¶
Overview ¶
Package ui owns every byte the CLI writes for human consumption: colours, tables, banners, progress. Nothing outside this package should reach for lipgloss directly, so that --no-color and --json have exactly one place to take effect.
Index ¶
- Variables
- func Accent(s string) string
- func Banner() string
- func Bold(s string) string
- func Command(s string) string
- func Dim(s string) string
- func Error(format string, args ...any)
- func Init(jsonOut, noColor bool)
- func JSON(v any) error
- func KV(label, value string)
- func List(pairs [][2]string, indent string) string
- func Newline()
- func Primary(s string) string
- func Printf(format string, args ...any)
- func Println(args ...any)
- func Secondary(s string) string
- func Section(title string)
- func StatusBadge(status string) string
- func Success(format string, args ...any)
- func Warn(format string, args ...any)
- func Warn2(s string) string
- type Table
Constants ¶
This section is empty.
Variables ¶
var ( Version = "dev" Commit = "unknown" )
Version is stamped at build time via -ldflags. See the Makefile.
var ( ColorPrimary = lipgloss.Color("#58A6FF") // EVE cyan-blue — headings, command names ColorSecondary = lipgloss.Color("#7C8DA6") // steel — supporting values ColorAccent = lipgloss.Color("#F85149") // killboard red — the KILL half of the logo ColorSuccess = lipgloss.Color("#56D364") ColorError = lipgloss.Color("#F85149") ColorWarn = lipgloss.Color("#E3B341") ColorDim = lipgloss.Color("#6E7681") ColorWhite = lipgloss.Color("#FFFFFF") )
Palette. Tuned for dark terminals, which is where this runs — the numbers are deliberately close to GitHub's dark theme so red reads as "loss" and cyan as "chrome" without any further explanation.
var ( StyleBold = lipgloss.NewStyle().Bold(true) StyleDim = lipgloss.NewStyle().Foreground(ColorDim) StylePrimary = lipgloss.NewStyle().Foreground(ColorPrimary) StyleSecondary = lipgloss.NewStyle().Foreground(ColorSecondary) StyleAccent = lipgloss.NewStyle().Foreground(ColorAccent) StyleSuccess = lipgloss.NewStyle().Foreground(ColorSuccess) StyleError = lipgloss.NewStyle().Foreground(ColorError) StyleWarn = lipgloss.NewStyle().Foreground(ColorWarn) StyleSection = lipgloss.NewStyle().Bold(true).Foreground(ColorPrimary) StyleCommand = lipgloss.NewStyle().Foreground(ColorSuccess) )
var ColorEnabled = true
ColorEnabled reports whether styled output is wanted. Every helper in this package must branch on it and emit plain ASCII when false — the CLI has to stay readable in `kubectl logs`, CI output, and pipes, which is exactly where a killboard operator reads it most.
var JSONMode = false
JSONMode suppresses all decorative output. Commands that support structured output check it before printing anything human-facing, so stdout carries only the JSON document and stays pipeable into jq.
Functions ¶
func Banner ¶
func Banner() string
Banner renders the logo plus version line, or a single plain line when colour is off. Nothing downstream should assume a fixed height.
func Bold ¶
Bold, Dim, Primary, Secondary, Accent and Command render a fragment in the requested style, or return it untouched when colour is off. They return strings rather than printing so callers can compose them into tables.
func Init ¶
func Init(jsonOut, noColor bool)
Init resolves output modes from the persistent flags plus the environment. Explicit flags win; otherwise we honour NO_COLOR and refuse to emit escape sequences when stdout is not a terminal.
func JSON ¶
JSON writes v as indented JSON to stdout. This is the one output path that deliberately ignores JSONMode — it *is* the JSON mode payload.
func List ¶
List renders label/description pairs with the labels aligned — the shape the help renderer wants for command listings. Labels are measured, not fixed, because command names vary a lot in length between groups.
func Section ¶
func Section(title string)
Section prints a group heading. Suppressed in JSON mode along with every other decoration.
func StatusBadge ¶
StatusBadge renders a health verdict. The plain-text form keeps the same column width intent by bracketing, so degraded `doctor` output still lines up when piped to a file.
Types ¶
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a thin builder over lipgloss's table with a plain-text fallback. The fallback is not a nicety: bordered box-drawing output is unreadable in log aggregators, and `doctor --json` aside, that is where most of this ends up being read.