pgr

package module
v0.0.0-...-7160724 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2019 License: BSD-3-Clause Imports: 13 Imported by: 0

README

pgr

Simple & Extensible progress bar library

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTemplate = template.Must(NewTemplate().Parse(`{{ percent . }} {{ bar . "[" "=" ">" " " "]" }}`))

`{{ percent . }} {{ bar . "[" "=" ">" " " "]" }}`

View Source
var ErrCanceled = errors.New("canceled by context")

Functions

func NewTemplate

func NewTemplate() *template.Template

template MUST NOT print newline.

Types

type Bar

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

func NewBar

func NewBar(total int64, tmpl *template.Template) *Bar

func NewBarFunc

func NewBarFunc(total int64, format FormatFunc) *Bar

func (*Bar) Add

func (bar *Bar) Add(n int64)

func (*Bar) Current

func (bar *Bar) Current() int64

func (*Bar) Finished

func (bar *Bar) Finished() bool

func (*Bar) Inc

func (bar *Bar) Inc()

func (*Bar) OnFinish

func (bar *Bar) OnFinish(tmpl *template.Template) *Bar

func (*Bar) OnFinishFunc

func (bar *Bar) OnFinishFunc(format FormatFunc) *Bar

func (*Bar) SetCurrent

func (bar *Bar) SetCurrent(current int64) *Bar

func (*Bar) SetTotal

func (bar *Bar) SetTotal(total int64) *Bar

XXX: https://code.google.com/p/go/issues/detail?id=5278

func (*Bar) Total

func (bar *Bar) Total() int64

type FormatFunc

type FormatFunc func(*Bar) string

type LessFunc

type LessFunc func(*Bar, *Bar) bool

type Poller

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

func NewPoller

func NewPoller(d time.Duration) *Poller

func (*Poller) Add

func (p *Poller) Add(bars ...*Bar) *Poller

func (*Poller) Poll

func (p *Poller) Poll() (lines int, err error)

poll() returns nil error if all bars are finished.

func (*Poller) SetDuration

func (p *Poller) SetDuration(d time.Duration)

func (*Poller) SetOut

func (p *Poller) SetOut(out io.Writer) error

func (*Poller) SetSorter

func (p *Poller) SetSorter(less LessFunc) *Poller

func (*Poller) Show

func (p *Poller) Show(ctx context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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