Documentation
¶
Overview ¶
Package progress 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 style.Emoji() is false.
Scheme rule: widgets paint through an optional style.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 ¶
NewBar builds a bar for total units with a description prefix. Narrow terminals shrink the bar to fit instead of wrapping.
func (*Bar) Add ¶
Add advances n units, redrawing the bar. Negative totals clamp at zero; overshoot clamps at the total.
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner draws a message with an animated prefix until Stop.
func NewSpinner ¶
NewSpinner builds a stopped spinner writing to w. Pass style.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) Start ¶
func (s *Spinner) Start()
Start begins animation. The message stays until Stop. Safe to call twice; only the first starts the loop.