ui

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package ui provides styled output helpers for CLI feedback using lipgloss. This file implements a spinner for long-running operations.

Package ui provides styled output helpers for CLI feedback using lipgloss. Colors are applied automatically when the writer is a TTY and stripped for pipes, CI, and direnv subprocesses.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bold

func Bold(w io.Writer, s string) string

Bold returns s in bold.

func Cyan

func Cyan(w io.Writer, s string) string

Cyan returns s in cyan.

func Error

func Error(w io.Writer, msg string)

Error prints a red cross line to w.

func Gray

func Gray(w io.Writer, s string) string

Gray returns s in muted gray.

func Green

func Green(w io.Writer, s string) string

Green returns s in green.

func Header(w io.Writer, title string)

Header prints a bold section title followed by a separator rule.

func Info

func Info(w io.Writer, msg string)

Info prints a cyan bullet line to w.

func Item

func Item(w io.Writer, key, value string)

Item prints an indented key/value row, key padded to 22 chars.

func List

func List(w io.Writer, names []string)

List prints each name as an indented bullet.

func Panel

func Panel(w io.Writer, title, headline string, entries []PanelEntry, border bool)

Panel prints a summary to w. When border is true a rounded box with the title embedded in the top edge is drawn; otherwise a compact single-header line with indented key/source rows is printed. Colors are stripped automatically on non-TTY writers.

func Red

func Red(w io.Writer, s string) string

Red returns s in red.

func Success

func Success(w io.Writer, msg string)

Success prints a green checkmark line to w.

func Warn

func Warn(w io.Writer, msg string)

Warn prints a yellow warning line to w.

func Yellow

func Yellow(w io.Writer, s string) string

Yellow returns s in yellow.

Types

type PanelEntry

type PanelEntry struct {
	Key    string // variable or item name
	Value  string // display value (may be empty)
	Source string // origin URI, e.g. "bw://folder/item"; empty = literal
}

PanelEntry is a single key/source row shown inside a Panel call.

type Spinner

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

Spinner provides animated progress feedback during long-running operations. Only renders to TTY outputs — silently suppressed for pipes, CI, and direnv.

Example

ExampleSpinner demonstrates basic spinner usage. This shows how to display progress while an operation runs.

spinner := NewSpinner(os.Stderr, "Loading secrets from Bitwarden...")
spinner.Start()

// Simulate work
time.Sleep(2 * time.Second)

// Update the message
spinner.SetMessage("Processing items...")
time.Sleep(1 * time.Second)

// Stop the spinner
spinner.Stop()

func NewSpinner

func NewSpinner(w io.Writer, message string) *Spinner

NewSpinner creates a spinner writing to w with the given initial message.

func (*Spinner) SetMessage

func (s *Spinner) SetMessage(msg string)

SetMessage updates the displayed message. Thread-safe.

func (*Spinner) Start

func (s *Spinner) Start()

Start begins the spinner animation. No-op if already running or not a TTY.

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop ends the animation and clears the spinner line. Safe to call multiple times.

Jump to

Keyboard shortcuts

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