pogs – git.sr.ht/~liliace/pogs Index | Files

package pogs

import "git.sr.ht/~liliace/pogs"

Package pogs provides thread-safe methods for displaying multiple progress bars in unix terminals.

Index

Types

type Bars

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

Bars controls a group of progress bars.

func NewBars

func NewBars() (*Bars, error)

NewBars instanciates a Bars struct. NewBars returns an error if it is unable to get the terminal width.

func (*Bars) Add

func (b *Bars) Add(i int)

Add increments the i-th progress bar by one unit.

func (*Bars) Done

func (b *Bars) Done()

Done tells the Bars struct that the user is done creating progress bars with Bars.NewBar. When all progress bars are complete, the cursor will move to the bottom and print a newline character for the next write to stdout to appear on a new line.

func (*Bars) NewBar

func (b *Bars) NewBar() (i int, err error)

NewBar creates a new progress bar and returns an index to pass to Bars.Add and Bars.Start. The progress bar is created but not displayed until called with Bars.Start.

The index is always the i-th progress bar created, starting at 0. If your program already keeps track of an index per progress bar (eg. creating one progress bar per iteration in an index-based loop), you may use it instead.

NewBar returns an error if Bars.Done has been called.

func (*Bars) Start

func (b *Bars) Start(i, total int)

Start sets the total units of the i-th progress bar and starts displaying it.

Source Files

pogs.go

Version
v1.0.0 (latest)
Published
Jun 11, 2024
Platform
linux/amd64
Imports
6 packages
Last checked
2 weeks ago

Tools for package owners.