Documentation ¶
Index ¶
- type Option
- func OptionClearOnFinish() Option
- func OptionEnableColorCodes(colorCodes bool) Option
- func OptionSetBytes(maxBytes int) Option
- func OptionSetBytes64(maxBytes int64) Option
- func OptionSetDescription(description string) Option
- func OptionSetRenderBlankState(r bool) Option
- func OptionSetTheme(t Theme) Option
- func OptionSetWidth(s int) Option
- func OptionSetWriter(w io.Writer) Option
- func OptionShowCount() Option
- func OptionShowIts() Option
- func OptionThrottle(duration time.Duration) Option
- type ProgressBar
- func (p *ProgressBar) Add(num int) error
- func (p *ProgressBar) Add64(num int64) error
- func (p *ProgressBar) Clear() error
- func (p *ProgressBar) Describe(description string)
- func (p *ProgressBar) Finish() error
- func (p *ProgressBar) Read(b []byte) (n int, err error)
- func (p *ProgressBar) RenderBlank() error
- func (p *ProgressBar) Reset()
- func (p *ProgressBar) Set(num int) error
- func (p *ProgressBar) Set64(num int64) error
- func (p *ProgressBar) State() State
- func (p *ProgressBar) Write(b []byte) (n int, err error)
- type Reader
- type State
- type Theme
Examples ¶
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 type all options need to adhere to
func OptionClearOnFinish ¶ added in v2.11.0
func OptionClearOnFinish() Option
OptionClearOnFinish will clear the bar once its finished
func OptionEnableColorCodes ¶ added in v2.3.0
OptionEnableColorCodes enables or disables support for color codes using mitchellh/colorstring
func OptionSetBytes ¶ added in v2.4.0
OptionSetBytes will also print the bytes/second
func OptionSetBytes64 ¶ added in v2.9.1
OptionSetBytes64 will also print the bytes/second
func OptionSetDescription ¶ added in v2.2.0
OptionSetDescription sets the description of the bar to render in front of it
func OptionSetRenderBlankState ¶
OptionSetRenderBlankState sets whether or not to render a 0% bar on construction
func OptionSetTheme ¶
OptionSetTheme sets the elements the bar is constructed of
func OptionSetWriter ¶
OptionSetWriter sets the output writer (defaults to os.StdOut)
func OptionShowCount ¶ added in v2.8.0
func OptionShowCount() Option
OptionShowCount will also print current count out of total
func OptionShowIts ¶ added in v2.5.0
func OptionShowIts() Option
OptionShowIts will also print the iterations/second
func OptionThrottle ¶ added in v2.7.0
OptionThrottle will wait the specified duration before updating again. The default duration is 0 seconds.
type ProgressBar ¶
type ProgressBar struct {
// contains filtered or unexported fields
}
ProgressBar is a thread-safe, simple progress bar
Example ¶
bar := New(100) bar.Add(10)
Output: 10% |████ | [0s:0s]
func NewOptions ¶
func NewOptions(max int, options ...Option) *ProgressBar
NewOptions constructs a new instance of ProgressBar, with any options you specify
func NewOptions64 ¶ added in v2.9.1
func NewOptions64(max int64, options ...Option) *ProgressBar
NewOptions64 constructs a new instance of ProgressBar, with any options you specify
func (*ProgressBar) Add ¶
func (p *ProgressBar) Add(num int) error
func (*ProgressBar) Add64 ¶ added in v2.9.1
func (p *ProgressBar) Add64(num int64) error
func (*ProgressBar) Clear ¶ added in v2.3.0
func (p *ProgressBar) Clear() error
Clear erases the progress bar from the current line
func (*ProgressBar) Describe ¶ added in v2.10.0
func (p *ProgressBar) Describe(description string)
Describe will change the description shown before the progress, which can be changed on the fly (as for a slow running process).
func (*ProgressBar) Finish ¶ added in v2.4.0
func (p *ProgressBar) Finish() error
Finish will fill the bar to full
func (*ProgressBar) Read ¶ added in v2.9.0
func (p *ProgressBar) Read(b []byte) (n int, err error)
Read implement io.Reader
func (*ProgressBar) RenderBlank ¶
func (p *ProgressBar) RenderBlank() error
RenderBlank renders the current bar state, you can use this to render a 0% state
Example ¶
NewOptions(10, OptionSetWidth(10), OptionSetRenderBlankState(true))
Output: 0% | | [0s:0s]
func (*ProgressBar) Reset ¶
func (p *ProgressBar) Reset()
Reset will reset the clock that is used to calculate current time and the time left.
func (*ProgressBar) Set ¶ added in v2.9.0
func (p *ProgressBar) Set(num int) error
Add with increase the current count on the progress bar
func (*ProgressBar) Set64 ¶ added in v2.9.1
func (p *ProgressBar) Set64(num int64) error
Add with increase the current count on the progress bar
func (*ProgressBar) State ¶ added in v2.6.0
func (p *ProgressBar) State() State
State returns the current state
type Reader ¶ added in v2.9.0
Reader is the progressbar io.Reader struct