ui

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 8 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var (
	Version = "dev"
	Commit  = "unknown"
)

Version is stamped at build time via -ldflags. See the Makefile.

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

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

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

func Accent(s string) string
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

func Bold(s string) string

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 Command

func Command(s string) string

func Dim

func Dim(s string) string

func Error

func Error(format string, args ...any)

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

func JSON(v any) error

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 KV

func KV(label, value string)

func List

func List(pairs [][2]string, indent string) string

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 Newline

func Newline()

func Primary

func Primary(s string) string

func Printf

func Printf(format string, args ...any)

func Println

func Println(args ...any)

func Secondary

func Secondary(s string) string

func Section

func Section(title string)

Section prints a group heading. Suppressed in JSON mode along with every other decoration.

func StatusBadge

func StatusBadge(status string) string

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.

func Success

func Success(format string, args ...any)

Success, Warn and Error are the three verdict lines. Success goes to stdout because it is part of a command's output; Warn and Error go to stderr so a caller piping stdout into jq still sees them.

func Warn

func Warn(format string, args ...any)

func Warn2

func Warn2(s string) string

Warn2 renders a fragment in the warning colour. Named to avoid colliding with output.go's Warn, which prints a whole line to stderr.

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.

func NewTable

func NewTable(headers ...string) *Table

func (*Table) Render

func (t *Table) Render() string

func (*Table) Row

func (t *Table) Row(cells ...string) *Table

Jump to

Keyboard shortcuts

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