ui

package
v1.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package ui provides terminal styling, hyperlinks, and a progress spinner. Colors are emitted as plain ANSI escapes, gated on a TTY check — nothing here queries the terminal, so there is no startup latency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Banner(s string) string

Banner renders s as a white-on-red bold label.

func Bold

func Bold(s string) string

Bold renders s in bold.

func Cyan

func Cyan(s string) string

Cyan renders s in cyan.

func Dim

func Dim(s string) string

Dim renders s faintly.

func Green

func Green(s string) string

Green renders s in green.

func IsStdoutTTY

func IsStdoutTTY() bool

IsStdoutTTY reports whether stdout is an interactive terminal.

func Link(text, url string) string

Link wraps text in an OSC 8 terminal hyperlink (zero visible width) when stdout is a TTY; otherwise returns plain text.

func Red

func Red(s string) string

Red renders s in red.

func SelectGrouped

func SelectGrouped(title string, items []SelectItem) (selected []int, ok bool, err error)

SelectGrouped shows an interactive grouped multi-select. Items must be ordered so that members of the same group are contiguous; a header row is rendered per group, and toggling it selects or deselects every item in that group.

Returns the indices of selected items (into items). ok is false if the user aborted (esc/q/ctrl+c). Implemented with raw terminal mode + the alternate screen (rather than a TUI framework that probes the terminal at startup), with a scrolling viewport so lists taller than the terminal work correctly.

func Underline

func Underline(s string) string

Underline renders s underlined.

func Yellow

func Yellow(s string) string

Yellow renders s in yellow.

Types

type SelectItem

type SelectItem struct {
	Group string // group label (e.g. workflow file)
	Label string // display label for the item
}

SelectItem is one selectable row belonging to a group.

type Spinner

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

Spinner is a progress indicator that animates only on a TTY. On a non-TTY it is silent until Stop prints the final message once.

func NewSpinner

func NewSpinner(initial string) *Spinner

NewSpinner starts a spinner with the given initial message (animated on a TTY).

func (*Spinner) Message

func (s *Spinner) Message(msg string)

Message updates the spinner's text. Safe to call on a nil spinner.

func (*Spinner) Stop

func (s *Spinner) Stop(final string)

Stop halts the animation and prints the final message (if any). Safe to call on a nil spinner, in which case nothing is printed.

Jump to

Keyboard shortcuts

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