style

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package style renders devrig's terminal output: colors, glyphs, and boxes that degrade gracefully. Color is used only on a capable TTY (respecting NO_COLOR / FORCE_COLOR / TERM=dumb, and enabling VT processing on Windows), and Unicode box/▮ glyphs fall back to ASCII where they may not render.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blue

func Blue(s string) string

func Bold

func Bold(s string) string

func BoldCyan

func BoldCyan(s string) string

func BoldMagenta

func BoldMagenta(s string) string

func Box

func Box(title string, rows []string) string

Box renders rows inside a rounded, titled border, indented two spaces. Rows may contain color escapes; widths are measured visibly so borders align. Falls back to ASCII corners when Unicode is unavailable.

func ColorEnabled

func ColorEnabled() bool

ColorEnabled reports whether ANSI color is active.

func Cyan

func Cyan(s string) string

func Dim

func Dim(s string) string

func Gray

func Gray(s string) string

func Green

func Green(s string) string
func Link(url string) string

Link renders a URL, using an OSC 8 hyperlink on capable terminals so it's clickable, and underlined cyan otherwise.

func Magenta

func Magenta(s string) string

func PadRight

func PadRight(s string, n int) string

PadRight pads s with spaces to a visible width of n.

func Red

func Red(s string) string

func Width

func Width(s string) int

Width returns the visible (printable) width of s, ignoring ANSI escapes.

func Yellow

func Yellow(s string) string

Types

type Glyphs

type Glyphs struct {
	TopLeft, TopRight, BotLeft, BotRight, H, V string
	Bullet, MidDot, Arrow                      string
	Running, Pending, Failed, Stopped, Check   string
}

Glyphs is the active glyph set (Unicode or ASCII fallback).

func G

func G() Glyphs

G returns the active glyph set.

type Spinner added in v0.36.0

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

Spinner shows an animated "working…" indicator for a long step. It animates in place (carriage return) only on a color-capable TTY; otherwise it prints a single static line at start so piped/CI output stays clean. Stop with Done / Fail to replace the line with a final ✓/✗.

func NewSpinner added in v0.36.0

func NewSpinner(label string) *Spinner

NewSpinner creates a spinner with the given label (no trailing punctuation).

func (*Spinner) Done added in v0.36.0

func (s *Spinner) Done(msg string)

Done replaces the spinner with a green check and msg (defaults to the label).

func (*Spinner) Fail added in v0.36.0

func (s *Spinner) Fail(msg string)

Fail replaces the spinner with a red mark and msg (defaults to the label).

func (*Spinner) Start added in v0.36.0

func (s *Spinner) Start()

Start begins the animation (or prints a static line when not on a TTY, or when verbose mode is streaming subprocess output that an in-place animation would otherwise scramble).

Jump to

Keyboard shortcuts

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