ui

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package ui provides terminal output helpers styled with charmbracelet/lipgloss. Color palette and patterns match the tapes CLI (pkg/cliui).

Index

Constants

This section is empty.

Variables

View Source
var (
	GreenColor  = lipgloss.Color("82")
	RedColor    = lipgloss.Color("196")
	CyanColor   = lipgloss.Color("39")
	YellowColor = lipgloss.Color("226")
	GrayColor   = lipgloss.Color("245")
	DimColor    = lipgloss.Color("241")
	LightColor  = lipgloss.Color("252")
)

Color palette (ANSI 256, matching tapes/pkg/cliui).

View Source
var (
	SuccessMark = lipgloss.NewStyle().Foreground(GreenColor).Render("\u2713")
	FailMark    = lipgloss.NewStyle().Foreground(RedColor).Render("\u2717")

	StepStyle   = lipgloss.NewStyle().Foreground(GrayColor)
	NameStyle   = lipgloss.NewStyle().Foreground(GreenColor).Bold(true)
	DimStyle    = lipgloss.NewStyle().Foreground(DimColor)
	HashStyle   = lipgloss.NewStyle().Foreground(CyanColor)
	HeaderStyle = lipgloss.NewStyle().Foreground(LightColor).Bold(true)
)

Shared styles for CLI output formatting.

Functions

func Bold

func Bold(format string, args ...interface{})

Bold prints a bold message to stderr.

func Box

func Box(w io.Writer, content string, borderColor lipgloss.Color)

Box renders content inside a rounded-border box to the given writer. The box fits to content width with 1-line vertical and 2-char horizontal padding, matching the gum style --border rounded --padding "1 2" pattern.

func Confirm

func Confirm(format string, args ...interface{}) bool

Confirm prompts the user with an interactive yes/no confirmation using charmbracelet/huh. Returns true if the user confirms, false otherwise. Defaults to "no" if the user presses enter without selecting.

func Error

func Error(format string, args ...interface{})

Error prints a red error to stderr.

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a duration for display (e.g. "12ms" or "3.2s").

func Info

func Info(format string, args ...interface{})

Info prints a dim indented detail line to stderr.

func Label

func Label(label, value string) string

Label renders a cyan label followed by a value, for use inside info panels.

func Mark

func Mark(err error) string

Mark returns a checkmark for nil errors or X mark for non-nil errors.

func StateStyle

func StateStyle(state string) lipgloss.Style

StateStyle returns a lipgloss style for color-coding sandbox states.

func Status

func Status(format string, args ...interface{})

Status prints a cyan status message to stderr.

func Step

func Step(w io.Writer, msg string, fn func() error) error

Step prints an animated spinner while fn runs, then replaces it with a checkmark or X mark and elapsed time. Matches tapes cliui.Step(). When the writer is not a TTY (piped output, CI), the spinner is skipped and only the final result line is printed.

func Success

func Success(format string, args ...interface{})

Success prints a green checkmark + message to stderr.

func Warn

func Warn(format string, args ...interface{})

Warn prints a yellow warning to stderr.

Types

type Spinner

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

Spinner provides a standalone animated progress indicator for long operations where Step() is not suitable (e.g. the daemon serve loop).

func NewSpinner

func NewSpinner(message string) *Spinner

NewSpinner creates a new spinner with the given message.

func (*Spinner) Start

func (s *Spinner) Start()

Start begins the spinner animation in a background goroutine.

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop halts the spinner animation and clears the line.

func (*Spinner) StopWithMessage

func (s *Spinner) StopWithMessage(format string, args ...interface{})

StopWithMessage halts the spinner and prints a final message.

type Table

type Table struct {
	Headers  []string
	Rows     [][]string
	StateCol int // index of the STATE column; -1 to disable color-coding
}

Table renders a styled table with headers and rows. Headers are rendered bold; the column at StateCol (if >= 0) gets color-coded.

func (*Table) Render

func (t *Table) Render(w io.Writer)

Render writes the styled table to w.

Jump to

Keyboard shortcuts

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