Documentation
¶
Overview ¶
Package progressbar implements a simple thread-safe console progress bar with some basic customization options.
Index ¶
- type Option
- func OptionClearOnFinish() Option
- func OptionDescription(s string) Option
- func OptionFullWidth() Option
- func OptionItsString(its string) Option
- func OptionShowBytes() Option
- func OptionShowCount() Option
- func OptionShowElapsed() Option
- func OptionShowIts() Option
- func OptionShowRemaining() Option
- func OptionSpinnerStyle(style int) Option
- func OptionTheme(theme Theme) Option
- func OptionThrottle(interval time.Duration) Option
- func OptionTotalRate() Option
- func OptionUseANSICodes() Option
- func OptionUseColorCodes() Option
- func OptionVisible(show bool) Option
- func OptionWidth(width int) Option
- func OptionWriter(w io.Writer) Option
- type ProgressBar
- func (p *ProgressBar) Add(delta int) error
- func (p *ProgressBar) Add64(delta int64) error
- func (p *ProgressBar) AddMax(delta int) error
- func (p *ProgressBar) AddMax64(delta int64) error
- func (p *ProgressBar) Clear() error
- func (p *ProgressBar) Close() (err error)
- func (p *ProgressBar) Finish() error
- func (p *ProgressBar) Max() int
- func (p *ProgressBar) Max64() int64
- func (p *ProgressBar) Read(b []byte) (n int, err error)
- func (p *ProgressBar) Reset()
- func (p *ProgressBar) Set(value int) error
- func (p *ProgressBar) Set64(value int64) error
- func (p *ProgressBar) SetDescription(s string)
- func (p *ProgressBar) SetMax(max int) error
- func (p *ProgressBar) SetMax64(max int64) error
- func (p *ProgressBar) State() State
- func (p *ProgressBar) Stop() error
- func (p *ProgressBar) String() string
- func (p *ProgressBar) Write(b []byte) (n int, err error)
- type Reader
- type State
- type Theme
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(p *ProgressBar)
Option is the general type for progress bar customization options.
func OptionClearOnFinish ¶
func OptionClearOnFinish() Option
OptionClearOnFinish makes progress bar disappear when it's finished (but not when stopped).
func OptionDescription ¶
OptionDescription sets progress bar's description label.
func OptionFullWidth ¶
func OptionFullWidth() Option
OptionFullWidth makes progress bar use full width of the console.
func OptionItsString ¶
OptionItsString sets what the iterations are called. The default is "it" which would display "it/s".
func OptionShowBytes ¶
func OptionShowBytes() Option
OptionShowBytes enables display in units of bytes/sec.
func OptionShowCount ¶
func OptionShowCount() Option
OptionShowCount enables display of current count out of total.
func OptionShowElapsed ¶ added in v3.13.103
func OptionShowElapsed() Option
OptionShowElapsed enables elapsed time display.
func OptionShowIts ¶
func OptionShowIts() Option
OptionShowIts enables display of iterations/second.
func OptionShowRemaining ¶ added in v3.13.103
func OptionShowRemaining() Option
OptionShowRemaining enables display of estimated remaining time in addition to elapsed time.
Has no effect on spinners as their estimated remaining time is unknown.
func OptionSpinnerStyle ¶ added in v3.13.104
OptionSpinnerStyle sets spinner's visual style. Default is 9.
Available styles are restricted to 9, 14 and 59.
func OptionTheme ¶
OptionTheme sets progress bar's composition elements.
func OptionThrottle ¶
OptionThrottle enables minimum time intervals between refreshing the progress bar.
Default interval is zero which makes progress bar refresh on every update.
func OptionTotalRate ¶
func OptionTotalRate() Option
OptionTotalRate enables plain total rate display instead of default recent average rate.
func OptionUseANSICodes ¶
func OptionUseANSICodes() Option
OptionUseANSICodes enables use of more optimized terminal I/O.
Only useful in environments with support for ANSI escape sequences.
func OptionUseColorCodes ¶ added in v3.13.103
func OptionUseColorCodes() Option
OptionUseColorCodes enables support for color codes.
func OptionVisible ¶ added in v3.13.103
OptionVisible sets whether the progress bar is shown in console.
On by default, but can be useful to omit progress bar display when output is redirected etc.
func OptionWriter ¶
OptionWriter sets progress bar's output writer (defaults to os.Stdout).
type ProgressBar ¶
ProgressBar is a simple customizable progress bar. It is safe for concurrent use by multiple goroutines.
func Default ¶
func Default(max int64, description ...string) *ProgressBar
Default creates a new ProgressBar with some reasonable default options.
With max == -1 it creates a spinner.
func DefaultBytes ¶
func DefaultBytes(maxBytes int64, description ...string) *ProgressBar
DefaultBytes creates a new ProgressBar for measuring bytes throughput with some reasonable default options.
With maxBytes == -1 it creates a spinner.
func New ¶
func New(max int, options ...Option) *ProgressBar
New constructs a new instance of ProgressBar with specified options.
With max == -1 it creates a spinner.
func New64 ¶
func New64(max int64, options ...Option) *ProgressBar
New64 constructs a new instance of ProgressBar with specified options.
With max == -1 it creates a spinner.
func (*ProgressBar) Add ¶
func (p *ProgressBar) Add(delta int) error
Add adds specified delta to progress bar's current value.
func (*ProgressBar) Add64 ¶
func (p *ProgressBar) Add64(delta int64) error
Add64 adds specified delta to progress bar's current value.
func (*ProgressBar) AddMax ¶
func (p *ProgressBar) AddMax(delta int) error
AddMax adds specified delta to progress bar's maximum value.
func (*ProgressBar) AddMax64 ¶
func (p *ProgressBar) AddMax64(delta int64) error
AddMax64 adds specified delta to progress bar's maximum value.
func (*ProgressBar) Clear ¶
func (p *ProgressBar) Clear() error
Clear erases progress bar from the current line.
func (*ProgressBar) Close ¶
func (p *ProgressBar) Close() (err error)
Close implements io.Closer, just in case.
func (*ProgressBar) Finish ¶
func (p *ProgressBar) Finish() error
Finish fills progress bar to full and starts a new line.
func (*ProgressBar) Max64 ¶
func (p *ProgressBar) Max64() int64
Max64 returns progress bar's maximum value.
func (*ProgressBar) Read ¶
func (p *ProgressBar) Read(b []byte) (n int, err error)
Read implements io.Reader, just in case.
func (*ProgressBar) Reset ¶
func (p *ProgressBar) Reset()
Reset resets progress bar to initial state.
func (*ProgressBar) Set ¶
func (p *ProgressBar) Set(value int) error
Set sets progress bar's current value.
func (*ProgressBar) Set64 ¶
func (p *ProgressBar) Set64(value int64) error
Set64 sets progress bar's current value.
func (*ProgressBar) SetDescription ¶
func (p *ProgressBar) SetDescription(s string)
SetDescription changes progress bar's description label.
func (*ProgressBar) SetMax ¶
func (p *ProgressBar) SetMax(max int) error
SetMax sets progress bar's maximum value at which it's considered full.
func (*ProgressBar) SetMax64 ¶
func (p *ProgressBar) SetMax64(max int64) error
SetMax64 sets progress bar's maximum value at which it's considered full.
func (*ProgressBar) State ¶
func (p *ProgressBar) State() State
State returns progress bar's current state.
func (*ProgressBar) Stop ¶
func (p *ProgressBar) Stop() error
Stop stops progress bar at current state.
func (*ProgressBar) String ¶
func (p *ProgressBar) String() string
String returns progress bar's current rendering.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is an io.Reader with a progress bar.
func NewReader ¶
func NewReader(r io.Reader, bar *ProgressBar) Reader
NewReader creates a new Reader with given io.Reader and progress bar.