Update progressbar library, use it's option to clear progress after finish
This commit is contained in:
2
vendor/github.com/schollz/progressbar/v2/README.md
generated
vendored
2
vendor/github.com/schollz/progressbar/v2/README.md
generated
vendored
@@ -12,7 +12,7 @@ A very simple thread-safe progress bar which should work on every OS without pro
|
||||
## Install
|
||||
|
||||
```
|
||||
go get -u github.com/schollz/progressbar
|
||||
go get -u github.com/schollz/progressbar/v2
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
7
vendor/github.com/schollz/progressbar/v2/go.mod
generated
vendored
7
vendor/github.com/schollz/progressbar/v2/go.mod
generated
vendored
@@ -1,3 +1,8 @@
|
||||
module github.com/schollz/progressbar/v2
|
||||
|
||||
require github.com/mitchellh/colorstring v0.0.0-20150917214807-8631ce90f286
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
|
||||
github.com/stretchr/objx v0.1.1 // indirect
|
||||
github.com/stretchr/testify v1.3.0
|
||||
)
|
||||
|
21
vendor/github.com/schollz/progressbar/v2/progressbar.go
generated
vendored
21
vendor/github.com/schollz/progressbar/v2/progressbar.go
generated
vendored
@@ -43,6 +43,8 @@ type state struct {
|
||||
|
||||
maxLineWidth int
|
||||
currentBytes float64
|
||||
|
||||
finished bool
|
||||
}
|
||||
|
||||
type config struct {
|
||||
@@ -61,6 +63,9 @@ type config struct {
|
||||
|
||||
// minimum time to wait in between updates
|
||||
throttleDuration time.Duration
|
||||
|
||||
// clear bar once finished
|
||||
clearOnFinish bool
|
||||
}
|
||||
|
||||
// Theme defines the elements of the bar
|
||||
@@ -152,6 +157,13 @@ func OptionThrottle(duration time.Duration) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// OptionClearOnFinish will clear the bar once its finished
|
||||
func OptionClearOnFinish() Option {
|
||||
return func(p *ProgressBar) {
|
||||
p.config.clearOnFinish = true
|
||||
}
|
||||
}
|
||||
|
||||
var defaultTheme = Theme{Saucer: "█", SaucerPadding: " ", BarStart: "|", BarEnd: "|"}
|
||||
|
||||
// NewOptions constructs a new instance of ProgressBar, with any options you specify
|
||||
@@ -288,6 +300,15 @@ func (p *ProgressBar) render() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// check if the progress bar is finished
|
||||
if p.state.finished || p.state.currentNum >= p.config.max {
|
||||
p.state.finished = true
|
||||
if p.config.clearOnFinish {
|
||||
// if the progressbar is finished, return
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// then, re-render the current progress bar
|
||||
w, err := renderProgressBar(p.config, p.state)
|
||||
if err != nil {
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@@ -6,7 +6,7 @@ github.com/mitchellh/colorstring
|
||||
github.com/rs/zerolog
|
||||
github.com/rs/zerolog/internal/cbor
|
||||
github.com/rs/zerolog/internal/json
|
||||
# github.com/schollz/progressbar/v2 v2.10.0
|
||||
# github.com/schollz/progressbar/v2 v2.11.0
|
||||
github.com/schollz/progressbar/v2
|
||||
# gitlab.com/pztrn/flagger v0.0.0-20190122123836-d429d7149cc9
|
||||
gitlab.com/pztrn/flagger
|
||||
|
Reference in New Issue
Block a user