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
Types ¶
type Bar ¶ added in v0.17.0
type Bar struct {
// contains filtered or unexported fields
}
func NewUnknownBar ¶ added in v0.17.0
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
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
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
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).