ui

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 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 Error

func Error(msg string)

Error prints a red cross and message to stderr.

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