progress

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package progress provides terminal progress bar utilities. This file implements a concurrent multi-bar renderer that uses bubbles/progress for bar styling and a lightweight inline render loop for multi-line in-place refresh — no bubbletea Program overhead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeTheme added in v0.17.0

func MakeTheme() progressbar.Theme

func NewSingleBar added in v0.17.0

func NewSingleBar(r io.Reader, total int64, current int64, oid plumbing.Hash, round int) (io.Reader, io.Closer)

Types

type Bar added in v0.17.0

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

func NewBar

func NewBar(description string, total int, quiet bool) *Bar

func NewUnknownBar added in v0.17.0

func NewUnknownBar(description string, quiet bool) *Bar

func (*Bar) Add added in v0.17.0

func (b *Bar) Add(n int)

func (*Bar) Exit added in v0.17.0

func (b *Bar) Exit()

func (*Bar) Finish added in v0.17.0

func (b *Bar) Finish()

func (*Bar) NewTeeReader added in v0.17.0

func (b *Bar) NewTeeReader(r io.Reader) io.Reader

type Indicators

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

func NewIndicators

func NewIndicators(description, completed string, total uint64, quiet bool) *Indicators

func (*Indicators) Add

func (i *Indicators) Add(n int)

func (*Indicators) Run

func (i *Indicators) Run(ctx context.Context)

func (*Indicators) Wait

func (i *Indicators) Wait()

type MultiBar added in v0.23.0

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

MultiBar manages a set of concurrent download progress bars. It renders them inline (in-place, multi-line) using only ANSI cursor sequences — no bubbletea Program, no terminal capability queries.

Typical usage:

mb := progress.NewMultiBar(width)
b1 := mb.AddBar("Downloading abc123")
b2 := mb.AddBar("Downloading def456")
go func() { /* use b1 */ }()
go func() { /* use b2 */ }()
_ = mb.Run(os.Stderr)

func NewMultiBar added in v0.23.0

func NewMultiBar(width int) *MultiBar

NewMultiBar creates a MultiBar using the given terminal width. Pass 0 to use the default fallback width (80 columns).

func (*MultiBar) AddBar added in v0.23.0

func (mb *MultiBar) AddBar(label string) *TransferBar

AddBar registers a new download task and returns its TransferBar. Must be called before MultiBar.Run.

func (*MultiBar) Run added in v0.23.0

func (mb *MultiBar) Run(w io.Writer) error

Run starts the inline render loop and blocks until every bar has been marked TransferBar.Complete or TransferBar.Fail. w is typically os.Stderr.

type TransferBar added in v0.23.0

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

TransferBar is the per-task progress handle returned by MultiBar.AddBar. It is safe for concurrent use from download goroutines.

func (*TransferBar) Complete added in v0.23.0

func (b *TransferBar) Complete()

Complete marks the task as successfully finished.

func (*TransferBar) Fail added in v0.23.0

func (b *TransferBar) Fail()

Fail marks the task as failed.

func (*TransferBar) ProxyReader added in v0.23.0

func (b *TransferBar) ProxyReader(r io.Reader) (io.Reader, io.Closer)

ProxyReader wraps r so that every Read advances the bar automatically. It returns an (io.Reader, io.Closer) pair to match the odb.DoTransfer callback signature; the Closer is a harmless no-op.

func (*TransferBar) SetCurrent added in v0.23.0

func (b *TransferBar) SetCurrent(current int64)

SetCurrent sets the number of bytes already transferred. Useful when resuming a partial download.

func (*TransferBar) SetTotal added in v0.23.0

func (b *TransferBar) SetTotal(total int64)

SetTotal sets the known total size in bytes. May be called more than once (e.g. after a redirect reveals Content-Length).

Jump to

Keyboard shortcuts

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