ui

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package ui formats the Tern CLI's terminal output: colors, symbols, spinners and tables. Color and animation turn off automatically when output is not a terminal, and NO_COLOR and FORCE_COLOR are honored.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Duration

func Duration(d time.Duration) string

Duration formats d compactly: "812ms", "1.4s".

func Size

func Size(n int64) string

Size formats a byte count: "512 B", "14.2 kB", "10.3 MB".

Types

type Printer

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

Printer writes styled output to w.

func New

func New(w io.Writer) *Printer

New returns a Printer for w, detecting whether w is a color terminal.

func (*Printer) Bold

func (p *Printer) Bold(s string) string

Bold styles s in bold.

func (*Printer) Brand

func (p *Printer) Brand(s string) string

Brand is Tern's accent color, a teal.

func (*Printer) Cyan

func (p *Printer) Cyan(s string) string

Cyan styles s in cyan, for commands and URLs.

func (*Printer) Dim

func (p *Printer) Dim(s string) string

Dim styles s faintly, for secondary information.

func (*Printer) Error

func (p *Printer) Error(err error)

Error prints an error with a red label, indenting continuation lines.

func (*Printer) Event

func (p *Printer) Event(symbol, format string, args ...any)

Event prints a timestamped status line, as used by the dev server.

func (*Printer) Failure

func (p *Printer) Failure(format string, args ...any)

Failure prints a line with a red cross.

func (*Printer) Green

func (p *Printer) Green(s string) string

Green styles s in green, for success.

func (*Printer) Printf

func (p *Printer) Printf(format string, args ...any)

Printf writes formatted output.

func (*Printer) Println

func (p *Printer) Println(args ...any)

Println writes a line.

func (*Printer) Red

func (p *Printer) Red(s string) string

Red styles s in red, for errors.

func (*Printer) Spin

func (p *Printer) Spin(label string) *Spinner

Spin starts a spinner for a step.

func (*Printer) Success

func (p *Printer) Success(format string, args ...any)

Success prints a line with a green check.

func (*Printer) Table

func (p *Printer) Table(rows [][]string, style func(col int, cell string) string)

Table writes rows as aligned columns. The first row is a header.

func (*Printer) Warn

func (p *Printer) Warn(format string, args ...any)

Warn prints a line with a yellow marker.

func (*Printer) Writer

func (p *Printer) Writer() io.Writer

Writer returns the underlying writer.

func (*Printer) Yellow

func (p *Printer) Yellow(s string) string

Yellow styles s in yellow, for warnings.

type Spinner

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

Spinner shows an animated step on terminals and a plain line elsewhere.

func (*Spinner) Done

func (s *Spinner) Done(note string)

Done ends the spinner with a check, the elapsed time and an optional note.

func (*Spinner) Fail

func (s *Spinner) Fail()

Fail ends the spinner with a cross.

Jump to

Keyboard shortcuts

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