progressbar
progressbar copied to clipboard
Option to leave progress bar visible after finished
Option to leave progress bar onscreen when finished. Useful for seeing counts and rates after completing a run.
Great! Would happily accept PR with this
Can I try this one for hacktoberfest?
@ibraimgm of course!
@vsekhar can you giv me more details or a demo where I can better understand your problem? On all the demos, the progress bar remain visible after the run.
Wait, but... https://github.com/schollz/progressbar/blob/2ec720b802af37dd2a1cadd64212e5d8777fad27/progressbar.go#L210
Confirming that progressbar.Default(100) keeps the progress bar visible on completion and the below hides it.
bar := progressbar.NewOptions(100,
progressbar.OptionClearOnFinish(),
)
@vsekhar Does this solve your issue?
If my program logs after the bar finishes, then depending on the cursor and output stream (I use go-ansi), the bar either disappears or gets merged/garbled with the next log message.
I think the issue is a lack of newline once the bar finishes. I think you need something like
if !p.config.clearOnFinish {
if _, err := io.WriteString(c.writer, "\n"); err != nil {
return err
}
}
inserted here.
Is this issue still open?. If it is can I pick it up?
@vidu171 Its open, go ahead!
Hi, I am not able to recreate this issue my bar is still visible after and it doesn't get merged/garbled with the next log message. Can you please tell me the steps or sample code to recreate this issue?
I was also having this issue, it seems the problem happens with p.config.userANSICodes is set to true only, since it clears the line after it was re-rendered for finish.
I think simple removing lines 628-633 should solve the issue:
https://github.com/schollz/progressbar/blob/master/progressbar.go#L628
Notice that when not using ANSI Codes, the clearing happen before teh re-rendering, here:
https://github.com/schollz/progressbar/blob/master/progressbar.go#L609
Simple 0.5 line fix, at least for the case with config.useANSICodes: https://github.com/schollz/progressbar/pull/140