ui

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package ui renders Bindle's terminal output: colors and symbols when stdout is a TTY, plain ASCII when piped or when NO_COLOR is set. No heavy dependencies — ANSI escapes plus a small TTY probe.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Printer

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

Printer renders styled output to a writer, downgrading to plain when needed.

func New

func New(w io.Writer) *Printer

New returns a Printer for w with auto color detection.

func (*Printer) Blue

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

func (*Printer) Bold

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

Style helpers (no-op without color).

func (*Printer) Bullet

func (p *Printer) Bullet(format string, a ...any)

Bullet prints an indented gray bullet line.

func (*Printer) Color

func (p *Printer) Color() bool

Color reports whether this printer emits ANSI styling.

func (*Printer) Cyan

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

func (*Printer) Dim

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

func (*Printer) Fail

func (p *Printer) Fail(format string, a ...any)

Fail prints an error line: "✗ msg".

func (*Printer) Gray

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

func (*Printer) Green

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

func (*Printer) Heading

func (p *Printer) Heading(format string, a ...any)

Heading prints a bold title.

func (*Printer) Info

func (p *Printer) Info(format string, a ...any)

Info prints a plain line.

func (*Printer) KeyVal

func (p *Printer) KeyVal(key, val string)

KeyVal prints an aligned "key: value" line with a dim key.

func (*Printer) OK

func (p *Printer) OK(format string, a ...any)

OK prints a success line: "✓ msg".

func (*Printer) Printf

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

Printf writes without a trailing newline.

func (*Printer) Red

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

func (*Printer) Spinner

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

Spinner returns a new spinner bound to this printer.

func (*Printer) Step

func (p *Printer) Step(format string, a ...any)

Step prints a progress step: "→ msg" (dim arrow).

func (*Printer) Warn

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

Warn prints a warning line: "! msg".

func (*Printer) Writer

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

Writer exposes the underlying writer (for tabwriter, etc.).

func (*Printer) Yellow

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

type Spinner

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

Spinner is a single-line progress indicator. On a TTY it animates in place; in plain mode it degrades to one "→ label" line per Start/Update (no animation, pipe-safe).

func (*Spinner) Start

func (s *Spinner) Start()

Start begins the spinner. Safe to call once.

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop ends the spinner, clearing the line (TTY) before the caller prints a final status (e.g. p.OK).

func (*Spinner) Update

func (s *Spinner) Update(format string, a ...any)

Update changes the label mid-spin.

Jump to

Keyboard shortcuts

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