progress

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package progress provides progress indication for CLI operations.

Package progress provides progress indication for CLI operations.

Package progress provides progress indication for CLI operations.

Package progress provides progress indication for CLI operations.

Index

Constants

View Source
const (
	// DefaultProgressWidth is the default width of the progress bar in characters.
	DefaultProgressWidth = 40
)

Default values for progress options.

Variables

This section is empty.

Functions

This section is empty.

Types

type BarProgress

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

BarProgress provides a visual progress bar for determinate operations.

func NewBar

func NewBar(opts Options) *BarProgress

NewBar creates a new bar progress indicator.

func (*BarProgress) Complete

func (b *BarProgress) Complete(message string)

Complete marks the progress as successfully completed.

func (*BarProgress) Fail

func (b *BarProgress) Fail(err error)

Fail marks the progress as failed with an error.

func (*BarProgress) Start

func (b *BarProgress) Start(message string)

Start begins progress indication with an initial message.

func (*BarProgress) Update

func (b *BarProgress) Update(percent float64, message string)

Update updates the progress bar with a new percentage and message.

type NoOpProgress

type NoOpProgress struct{}

NoOpProgress is a no-operation progress indicator. It implements the Progress interface but does nothing. This is used in quiet mode or non-TTY environments.

func NewNoOp

func NewNoOp() *NoOpProgress

NewNoOp creates a new no-operation progress indicator.

func (*NoOpProgress) Complete

func (n *NoOpProgress) Complete(_ string)

Complete does nothing for no-op progress.

func (*NoOpProgress) Fail

func (n *NoOpProgress) Fail(_ error)

Fail does nothing for no-op progress.

func (*NoOpProgress) Start

func (n *NoOpProgress) Start(_ string)

Start does nothing for no-op progress.

func (*NoOpProgress) Update

func (n *NoOpProgress) Update(_ float64, _ string)

Update does nothing for no-op progress.

type Options

type Options struct {
	// Output is the writer for progress output (default: os.Stderr).
	Output io.Writer

	// Width is the width of the progress bar in characters.
	Width int

	// ShowPercentage shows the percentage alongside the progress.
	ShowPercentage bool

	// Enabled controls whether progress is shown at all.
	Enabled bool
}

Options configures progress indicator behavior.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns the default progress options.

type Progress

type Progress interface {
	// Start begins progress indication with an initial message.
	Start(message string)

	// Update updates the progress with a percentage (0.0 to 1.0) and message.
	Update(percent float64, message string)

	// Complete marks the progress as successfully completed.
	Complete(message string)

	// Fail marks the progress as failed with an error.
	Fail(err error)
}

Progress defines the interface for progress indication. Implementations can provide different visual representations (spinner, bar, percentage, or no-op for quiet mode).

func New

func New(opts Options) Progress

New creates a new progress indicator based on the environment and options. It automatically selects the best implementation based on: - Whether output is a terminal - Whether progress is enabled - Available terminal capabilities.

func NewForMultiFile

func NewForMultiFile(opts Options) Progress

NewForMultiFile creates a progress indicator suitable for multi-file operations. It uses a bar-style indicator that can show overall progress.

type SpinnerProgress

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

SpinnerProgress provides a spinning indicator for indeterminate operations.

func NewSpinner

func NewSpinner(opts Options) *SpinnerProgress

NewSpinner creates a new spinner progress indicator.

func (*SpinnerProgress) Complete

func (s *SpinnerProgress) Complete(message string)

Complete stops the spinner and shows a success message.

func (*SpinnerProgress) Fail

func (s *SpinnerProgress) Fail(err error)

Fail stops the spinner and shows an error message.

func (*SpinnerProgress) Start

func (s *SpinnerProgress) Start(message string)

Start begins the spinner animation with the given message.

func (*SpinnerProgress) Update

func (s *SpinnerProgress) Update(_ float64, message string)

Update updates the spinner message. The percent is ignored for spinners.

Jump to

Keyboard shortcuts

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