output

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bulletf added in v0.6.0

func Bulletf(marker, format string, args ...any)

Bulletf prints an indented list item to stdout. marker is a literal prefix (e.g. "+", "-", or "") so summaries can show add/remove glyphs. Infof-level.

func ColorEnabled added in v0.2.0

func ColorEnabled(w io.Writer) bool

ColorEnabled reports whether ANSI color should be emitted to w, honoring the --color mode, the NO_COLOR convention, and TTY detection.

func Colorize added in v0.2.0

func Colorize(w io.Writer, s string, codes ...Color) string

Colorize wraps s in ANSI escape sequences for the given colors when w is a terminal and NO_COLOR is unset; returns s unchanged otherwise.

func Errorf

func Errorf(format string, args ...any)

func Failuref added in v0.6.0

func Failuref(format string, args ...any)

Failuref prints a red "✗ …" line to stderr. Always emitted.

func Hintf added in v0.6.0

func Hintf(format string, args ...any)

Hintf prints a cyan "→ …" remediation line to stderr. Always emitted.

func Infof

func Infof(format string, args ...any)

func Printf

func Printf(format string, args ...any)

func ReportError added in v0.6.0

func ReportError(err error)

ReportError renders err to stderr in the house style:

  • a cancelled context prints "Interrupted." and nothing else;
  • a joined error (Unwrap() []error) prints "✗ <cause>" per line under a header;
  • a report.Hinted appends a "→ <hint>" line.

func Section added in v0.6.0

func Section(title string)

Section prints a bold section title to stdout. Part of primary output, so it is not suppressed by --quiet (inspection output should always show).

func SetColorMode added in v0.6.0

func SetColorMode(m ColorMode)

SetColorMode records the global --color preference.

func SetQuiet

func SetQuiet(q bool)

func Successf added in v0.6.0

func Successf(format string, args ...any)

Successf prints a green "✓ …" line to stdout. Infof-level (suppressed by -q).

func Symbol added in v0.6.0

func Symbol(w io.Writer, r Role) string

Symbol returns the theme-appropriate glyph for role r and writer w.

func Upgradedf added in v0.6.0

func Upgradedf(name, oldVersion, newVersion string)

Upgradedf prints a green "✓ <name> <old> → <new>" line to stdout. The transition arrow is theme-aware (→ or ->), resolved against the same writer the line is rendered to. Infof-level (suppressed by -q).

func Warnf

func Warnf(format string, args ...any)

Types

type Color added in v0.2.0

type Color int
const (
	Red Color = iota
	Green
	Yellow
	Blue
	Magenta
	Cyan
	Dim
	Bold
)

type ColorMode added in v0.6.0

type ColorMode int

ColorMode overrides automatic TTY/NO_COLOR color detection. ColorAuto is the default.

const (
	ColorAuto ColorMode = iota
	ColorAlways
	ColorNever
)

func ParseColorMode added in v0.6.0

func ParseColorMode(s string) ColorMode

ParseColorMode maps a --color flag value to a ColorMode. Unknown values fall back to ColorAuto so a typo degrades rather than fails the command.

type KeyValues added in v0.6.0

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

KeyValues renders aligned label/value pairs with bold labels.

func NewKeyValues added in v0.6.0

func NewKeyValues() *KeyValues

func (*KeyValues) Add added in v0.6.0

func (k *KeyValues) Add(label, value string)

func (*KeyValues) Flush added in v0.6.0

func (k *KeyValues) Flush()

Flush writes every pair, right-padding labels so values align in a column.

type Role added in v0.6.0

type Role int

Role identifies a semantic marker whose glyph adapts to the writer's theme.

const (
	RoleSuccess Role = iota
	RoleFailure
	RoleSkip
	RoleHint
)

type Spinner added in v0.6.0

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

Spinner is an indeterminate activity indicator. On a TTY it animates a frame + label + elapsed counter in place; off-TTY (or under --quiet) it degrades to a start line and a terminal status line.

func NewSpinner added in v0.6.0

func NewSpinner(label string) *Spinner

NewSpinner creates a spinner for label. Call Start, then exactly one of Stop or Fail.

func (*Spinner) Fail added in v0.6.0

func (s *Spinner) Fail(error)

Fail ends the spinner with a red "✗ <label>" status line. The error detail is surfaced by the caller's normal error path (the downstream sink), so it is deliberately not repeated here.

func (*Spinner) Start added in v0.6.0

func (s *Spinner) Start()

func (*Spinner) Stop added in v0.6.0

func (s *Spinner) Stop(final string)

Stop ends the spinner with a green "✓ <final>" line.

type Table

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

func NewTable

func NewTable() *Table

func NewTableWriter

func NewTableWriter(out io.Writer) *Table

func (*Table) Flush

func (t *Table) Flush() error

func (*Table) Row

func (t *Table) Row(cols ...string)

type Theme added in v0.6.0

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

Theme captures the resolved rendering capabilities for a single writer.

type Tracker

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

Tracker renders multi-job download progress. On a TTY it owns the stdout cursor directly, repainting its block outside live.mu — unlike Spinner, which coordinates every repaint through it. It must therefore not animate while a Spinner is active or while other lines are written to a TTY; pkg.Manager upholds this by stopping the tracker before opening any install-phase spinner. Off a TTY it does no cursor painting at all — Update/Done/Fail emit plain lines instead — so the cursor-ownership invariant is a TTY-only concern.

func NewTracker

func NewTracker() *Tracker

func (*Tracker) Add

func (t *Tracker) Add(name string)

func (*Tracker) Done

func (t *Tracker) Done(name string)

func (*Tracker) Fail

func (t *Tracker) Fail(name string, err error)

func (*Tracker) Start

func (t *Tracker) Start()

func (*Tracker) Stop

func (t *Tracker) Stop()

Stop is safe to call more than once and is a no-op if Start was never called. The sync.Once protects the channel close; the atomic `started` flag protects against blocking forever on a `done` that no goroutine will ever close.

func (*Tracker) Update

func (t *Tracker) Update(name string, downloaded, total int64)

Jump to

Keyboard shortcuts

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