termprogress

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package termprogress owns spinners and bars. Apps never construct the underlying widgets directly: every widget shares one caller-provided writer (the render output), so concurrent spinners, bars, and logs cannot garble each other at the file level.

Live-tree rule: stop (or never start) InteractiveRenderer drawing while a spinner or bar runs, and resume after. The widgets draw with their own escape traffic, which fights the tree's incremental redraws. Pipes, CI, and dumb terminals need no pausing: nothing live draws there.

Terminal rule: spinners animate only when their destination is a terminal; Start elsewhere is a safe no-op. Bars always render (they degrade to plain lines), so CI logs keep full progress.

Frame rule: braille dots on capable terminals, plain ASCII spinners (|/-\ differences) on legacy Windows consoles and anywhere else termcore.Emoji() is false.

Scheme rule: widgets paint through an optional termstyle.Scheme (WithScheme); the zero scheme stays plain, so pipes and CI logs keep raw text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bar

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

Bar draws a labeled progress bar to w. Bars render everywhere, including pipes and CI logs: every Add prints one updated line, so output stays readable without cursor control.

func NewBar

func NewBar(w io.Writer, total int, description string) *Bar

NewBar builds a bar for total units with a description prefix. Narrow terminals shrink the bar to fit instead of wrapping.

func (*Bar) Add

func (b *Bar) Add(n int) error

Add advances n units, redrawing the bar. Negative totals clamp at zero; overshoot clamps at the total.

func (*Bar) Finish

func (b *Bar) Finish() error

Finish fills the bar and ends the line. Safe to call twice.

func (*Bar) WithScheme

func (b *Bar) WithScheme(scheme termstyle.Scheme) *Bar

WithScheme paints the filled run through scheme; the zero Scheme keeps the bar plain, so pipes and CI logs stay raw text.

type Spinner

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

Spinner draws a message with an animated prefix until Stop.

func NewSpinner

func NewSpinner(w io.Writer, message string, emoji bool) *Spinner

NewSpinner builds a stopped spinner writing to w. Pass termcore.Emoji() as emoji to pick dots vs ASCII frames.

Animation runs only when the destination is a terminal: Start on a pipe, file, or CI log is a safe no-op (nothing draws, nothing hangs), so callers never branch on interactivity themselves.

func (*Spinner) Active

func (s *Spinner) Active() bool

Active reports whether the spinner is animating.

func (*Spinner) Start

func (s *Spinner) Start()

Start begins animation. The message stays until Stop. Safe to call twice; only the first starts the loop.

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop ends animation and restores the line. Safe to call twice and without Start.

func (*Spinner) WithScheme

func (s *Spinner) WithScheme(scheme termstyle.Scheme) *Spinner

WithScheme paints the frame through scheme; the zero Scheme keeps frames plain, so widgets stay plain unless callers opt in.

Jump to

Keyboard shortcuts

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