ui

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Styles
	Reset     = "\033[0m"
	Bold      = "\033[1m"
	Dim       = "\033[2m"
	Underline = "\033[4m"

	// Foreground
	Black   = "\033[0;30m"
	Red     = "\033[0;31m"
	Green   = "\033[0;32m"
	Yellow  = "\033[0;33m"
	Blue    = "\033[0;34m"
	Magenta = "\033[0;35m"
	Cyan    = "\033[0;36m"
	White   = "\033[0;37m"

	// Bright (for high-visibility)
	BrightRed    = "\033[1;31m"
	BrightGreen  = "\033[1;32m"
	BrightYellow = "\033[1;33m"

	// Background (rare, for critical alerts)
	BgRed    = "\033[41m"
	BgGreen  = "\033[42m"
	BgYellow = "\033[43m"
	BgBlue   = "\033[44m"
)

ANSI color and style constants.

View Source
const (
	IconSuccess = "\u2713" // ✓ — success, healthy, done
	IconFailure = "\u2717" // ✗ — error, failed
	IconWarning = "\u26A0" // ⚠ — warning
	IconInfo    = "\u2139" // ℹ — informational
	IconArrow   = "\u2192" // → — next steps, navigation, section header
	IconBullet  = "\u2022" // • — list items

)

Unicode icon constants for terminal output.

Variables

This section is empty.

Functions

func Bullet

func Bullet(item string)

Bullet prints an indented bullet point with a blue bullet icon.

func C

func C(color, text string) string

C wraps text in the given ANSI color code if colors are enabled. Returns plain text otherwise.

func Checked

func Checked(item string)

Checked prints a green checkmark list item.

func CommandHeader

func CommandHeader(title, subtitle string)

CommandHeader prints a 60-char wide double-line box with title and subtitle. Every command starts with this header.

func CommandHeaderStderr

func CommandHeaderStderr(title, subtitle string)

CommandHeaderStderr prints the command header to stderr. Use this for commands whose stdout output is machine-readable (URLs, values, JSON).

func Dimmed

func Dimmed(msg string)

Dimmed prints gray/dim text to stdout.

func DockerPullProgress added in v1.0.12

func DockerPullProgress(quiet bool) func(error)

DockerPullProgress prints an animated Docker pull progress indicator. It returns a done-func that, when called, clears the line and prints completion.

func Error

func Error(msg string)

Error prints a red cross and message to stderr.

func FirstRunProgress added in v1.0.11

func FirstRunProgress(quiet bool) func()

FirstRunProgress prints a first-run progress note to stdout. It outputs a static one-liner in non-TTY/quiet mode and a timed line in TTY mode. Returns a done function that must be called when the pull is complete.

func Info

func Info(msg string)

Info prints a blue info icon and message to stdout.

func PrintJSON

func PrintJSON(v interface{}) error

PrintJSON marshals v to indented JSON (2-space indent) and writes it to stdout.

func PrintJSONError

func PrintJSONError(err error)

PrintJSONError writes a JSON error object {"error": "message"} to stderr.

func Section

func Section(title string)

Section prints a newline, blue arrow, and bold title to stdout.

func Separator

func Separator()

Separator prints a 60-char dim horizontal line.

func Step

func Step(current, total int, message string)

Step prints a step counter line: ⚙ Step N/M - message.

func Success

func Success(msg string)

Success prints a green checkmark and message to stdout.

func SummaryBox

func SummaryBox(title string, items []string)

SummaryBox prints a green double-line box with a star-decorated title and bulleted items.

func UXError

func UXError(problem, context string, solutions []string)

UXError prints a structured error to stderr with problem, context, and solutions.

func Unchecked

func Unchecked(item string)

Unchecked prints a dimmed pending list item.

func Warn

func Warn(msg string)

Warn prints a yellow warning icon and message to stderr.

Types

type InitSteps added in v1.0.12

type InitSteps struct {
	// contains filtered or unexported fields
}

InitSteps renders a multi-step progress display for nself init. Each call to Next() advances one step and prints the current step label.

func NewInitSteps added in v1.0.12

func NewInitSteps(quiet bool, steps ...string) *InitSteps

NewInitSteps creates an InitSteps tracker for the given ordered step labels.

func (*InitSteps) Done added in v1.0.12

func (s *InitSteps) Done()

Done prints the final "all done" summary line.

func (*InitSteps) Next added in v1.0.12

func (s *InitSteps) Next() bool

Next advances to the next step, printing its label. Returns false when all steps are consumed.

type ProgressBar added in v1.0.12

type ProgressBar struct {
	// contains filtered or unexported fields
}

ProgressBar renders a terminal progress bar with percentage and elapsed time. It is safe to call from a single goroutine; updates are synchronous.

func NewProgressBar added in v1.0.12

func NewProgressBar(label string, total int, quiet bool) *ProgressBar

NewProgressBar creates a ProgressBar with the given label and total steps. Width defaults to 40 characters of fill area.

func (*ProgressBar) Done added in v1.0.12

func (p *ProgressBar) Done()

Done marks the bar at 100% and prints a newline.

func (*ProgressBar) Inc added in v1.0.12

func (p *ProgressBar) Inc()

Inc increments the bar by one step.

func (*ProgressBar) Set added in v1.0.12

func (p *ProgressBar) Set(n int)

Set advances the bar to an absolute position (0..total).

type Spinner

type Spinner struct {
	// contains filtered or unexported fields
}

Spinner provides a goroutine-based terminal spinner with braille animation.

func NewSpinner

func NewSpinner(message string) *Spinner

NewSpinner creates a new Spinner with the given message.

func (*Spinner) Fail

func (s *Spinner) Fail(msg string)

Fail stops the spinner and prints a red cross with the given message to stderr.

func (*Spinner) Start

func (s *Spinner) Start()

Start begins the spinner animation in a background goroutine. In non-TTY environments, it prints "... message" once with no animation.

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop halts the spinner goroutine and clears the current line.

func (*Spinner) Success

func (s *Spinner) Success(msg string)

Success stops the spinner and prints a green checkmark with the given message.

type Table

type Table struct {
	Headers []string
	Rows    [][]string
	Widths  []int // auto-calculated from data
}

Table renders data as a box-drawing table to stdout.

func NewTable

func NewTable(headers ...string) *Table

NewTable creates a new table with the given column headers.

func (*Table) AddRow

func (t *Table) AddRow(values ...string)

AddRow appends a row of values to the table.

func (*Table) Render

func (t *Table) Render()

Render outputs the table with box-drawing characters to stdout.

Jump to

Keyboard shortcuts

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