progress

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SpinnerDots   = SpinnerStyle{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}
	SpinnerLine   = SpinnerStyle{"-", "\\", "|", "/"}
	SpinnerArrows = SpinnerStyle{"←", "↖", "↑", "↗", "→", "↘", "↓", "↙"}
)

Predefined spinner styles.

Functions

func IsInteractive

func IsInteractive() bool

IsInteractive checks if the terminal is interactive. Checks if stdout or stderr is a terminal (not stdin, which may be piped).

Types

type Bar

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

Bar displays a progress bar.

func (*Bar) Fail

func (b *Bar) Fail(message string)

Fail displays failure message.

func (*Bar) Render

func (b *Bar) Render() string

Render generates progress bar string.

func (*Bar) Start

func (b *Bar) Start(message string)

Start begins progress display.

func (*Bar) Stop

func (b *Bar) Stop(message string)

Stop completes progress display.

func (*Bar) Update

func (b *Bar) Update(current, total int, message string)

Update updates progress.

type Config

type Config struct {
	Enabled     bool
	Interactive bool // Terminal supports cursor control
	Width       int
}

Config for progress indicators.

type Indicator

type Indicator interface {
	Start(message string)
	Update(current, total int, message string)
	Stop(message string)
	Fail(message string)
}

Indicator provides progress feedback.

func New

func New(cfg Config) Indicator

New creates appropriate indicator for terminal.

func NewBar

func NewBar(cfg Config) Indicator

NewBar creates a progress bar indicator.

func NewSpinner

func NewSpinner(cfg Config) Indicator

NewSpinner creates a spinner indicator.

type NoOpIndicator

type NoOpIndicator struct{}

NoOpIndicator does nothing (for non-interactive terminals).

func (*NoOpIndicator) Fail

func (n *NoOpIndicator) Fail(message string)

Fail does nothing.

func (*NoOpIndicator) Start

func (n *NoOpIndicator) Start(message string)

Start does nothing.

func (*NoOpIndicator) Stop

func (n *NoOpIndicator) Stop(message string)

Stop does nothing.

func (*NoOpIndicator) Update

func (n *NoOpIndicator) Update(current, total int, message string)

Update does nothing.

type Spinner

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

Spinner displays an indeterminate progress spinner.

func NewSpinnerWithStyle

func NewSpinnerWithStyle(cfg Config, style SpinnerStyle) *Spinner

NewSpinnerWithStyle creates a spinner with the specified style.

func (*Spinner) Fail

func (s *Spinner) Fail(message string)

Fail displays failure message.

func (*Spinner) Spin

func (s *Spinner) Spin()

Spin advances to next frame.

func (*Spinner) Start

func (s *Spinner) Start(message string)

Start begins spinner animation.

func (*Spinner) Stop

func (s *Spinner) Stop(message string)

Stop completes spinner display.

func (*Spinner) Update

func (s *Spinner) Update(current, total int, message string)

Update updates the message.

type SpinnerStyle

type SpinnerStyle []string

SpinnerStyle defines the animation frames for a spinner.

type Stage

type Stage struct {
	Name    string
	Total   int
	Current int
}

Stage represents one stage of a multi-stage operation.

type Tracker

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

Tracker manages progress for multi-stage operations.

func NewTracker

func NewTracker(stages []Stage, indicator Indicator) (*Tracker, error)

NewTracker creates a new progress tracker.

func (*Tracker) Advance

func (t *Tracker) Advance()

Advance moves to next stage.

func (*Tracker) Complete

func (t *Tracker) Complete(message string)

Complete completes tracking.

func (*Tracker) CurrentStage

func (t *Tracker) CurrentStage() int

CurrentStage returns the current stage index.

func (*Tracker) Fail

func (t *Tracker) Fail(message string)

Fail fails tracking.

func (*Tracker) Start

func (t *Tracker) Start()

Start begins tracking.

func (*Tracker) TotalStages

func (t *Tracker) TotalStages() int

TotalStages returns the total number of stages.

func (*Tracker) UpdateCurrent

func (t *Tracker) UpdateCurrent(current int, message string)

UpdateCurrent updates current stage progress.

Jump to

Keyboard shortcuts

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