Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish() should update state.currentBytes #182

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions progressbar.go
Expand Up @@ -494,10 +494,7 @@ func (p *ProgressBar) Reset() {

// Finish will fill the bar to full
func (p *ProgressBar) Finish() error {
p.lock.Lock()
p.state.currentNum = p.config.max
p.lock.Unlock()
return p.Add(0)
return p.Set64(p.config.max)
}

// Exit will exit the bar to keep current state
Expand Down
6 changes: 4 additions & 2 deletions progressbar_test.go
Expand Up @@ -94,10 +94,12 @@ func ExampleOptionClearOnFinish() {
}

func ExampleProgressBar_Finish() {
bar := NewOptions(100, OptionSetWidth(10))
bar := NewOptions(100, OptionSetWidth(10), OptionShowCount(), OptionShowBytes(true), OptionShowIts())
bar.Reset()
time.Sleep(1 * time.Second)
bar.Finish()
// Output:
// 100% |██████████|
// 100% |██████████| (100/100 B, 100 B/s, 100 it/s)
}

func Example_xOutOfY() {
Expand Down