progress

package
v0.4.10 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package progress provides progress reporting for long-running operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoEnabled

func AutoEnabled(writer io.Writer) bool

AutoEnabled reports whether terminal progress output is appropriate.

func Noop

func Noop(op string, current, total int, message string)

Noop is a no-op callback for default behavior.

Types

type Callback

type Callback func(op string, current, total int, message string)

Callback receives progress updates during long operations.

type CountingTerminal

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

CountingTerminal is a progress bar for counting operations where the total isn't known upfront.

func NewCountingTerminal

func NewCountingTerminal(op string, enabled bool) *CountingTerminal

NewCountingTerminal creates a new counting terminal progress bar.

func (*CountingTerminal) Done

func (t *CountingTerminal) Done(finalMessage string)

Done marks the operation as complete.

func (*CountingTerminal) Increment

func (t *CountingTerminal) Increment()

Increment advances the counter.

func (*CountingTerminal) SetEnabled

func (t *CountingTerminal) SetEnabled(enabled bool)

SetEnabled enables or disables the progress bar.

type Progress

type Progress struct {
	Op    string
	Total int
	// contains filtered or unexported fields
}

Progress tracks operation progress.

func New

func New(op string, total int, cb Callback) *Progress

New creates a new Progress tracker.

func (*Progress) Current

func (p *Progress) Current() int

Current returns the current progress value.

func (*Progress) Done

func (p *Progress) Done(message string)

Done marks the operation as complete.

func (*Progress) Increment

func (p *Progress) Increment(message string)

Increment advances the progress and calls the callback.

func (*Progress) Set

func (p *Progress) Set(current int, message string)

Set sets the current progress value.

type Terminal

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

Terminal provides a terminal-based progress bar.

func NewTerminal

func NewTerminal(op string, total int, enabled bool) *Terminal

NewTerminal creates a new terminal progress bar.

func (*Terminal) Callback

func (t *Terminal) Callback() Callback

Callback returns a Callback function for this terminal.

func (*Terminal) Done

func (t *Terminal) Done(message string)

Done marks the operation as complete and prints a final newline.

func (*Terminal) IsEnabled

func (t *Terminal) IsEnabled() bool

IsEnabled returns whether the progress bar is enabled.

func (*Terminal) SetEnabled

func (t *Terminal) SetEnabled(enabled bool)

SetEnabled enables or disables the progress bar.

Jump to

Keyboard shortcuts

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