Documentation ¶
Index ¶
- type Option
- func OptionEnableColorCodes(colorCodes bool) Option
- func OptionSetBytes(maxBytes int) 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 OptionShowIts() Option
- func OptionThrottle(duration time.Duration) Option
- type ProgressBar
- 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 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 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 OptionShowIts ¶ added in v2.5.0
func OptionShowIts() Option
OptionShowIts will also print the iterations/second
func OptionThrottle ¶ added in v2.7.0
OptionShowIts will also print the iterations/second
type ProgressBar ¶
type ProgressBar struct {
// contains filtered or unexported fields
}
ProgressBar is a thread-safe, simple progress bar
Example ¶
bar := NewOptions(100, OptionSetWidth(10), OptionSetRenderBlankState(false)) bar.Reset() time.Sleep(1 * time.Second) bar.Add(10)
Output: 10% |█ | [1s:9s]
func NewOptions ¶
func NewOptions(max int, options ...Option) *ProgressBar
NewOptions constructs a new instance of ProgressBar, with any options you specify
func (*ProgressBar) Add ¶
func (p *ProgressBar) Add(num int) error
Add with increase the current count on the progress bar
func (*ProgressBar) Clear ¶ added in v2.3.0
func (p *ProgressBar) Clear() error
Clear erases the progress bar from the current line
func (*ProgressBar) Finish ¶ added in v2.4.0
func (p *ProgressBar) Finish() error
Finish will fill the bar to full
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) State ¶ added in v2.6.0
func (p *ProgressBar) State() State
State returns the current state