progressbar icon indicating copy to clipboard operation
progressbar copied to clipboard

How to display all steps in spinner

Open jazzboME opened this issue 2 years ago • 1 comments

I'm trying this code:

func main() {
	bar := progressbar.NewOptions(-1,
		progressbar.OptionSetDescription("spinnertest"),
		progressbar.OptionShowIts(),
		progressbar.OptionShowCount(),
		progressbar.OptionSpinnerType(7),
	)

	for i:=0; i < 100; i++ {
		bar.Add(1)
		time.Sleep(1 * time.Second)
	}
}

And I'm expecting that each time it updates, it would move 1 step in the spinner, instead it just flops back and forth between 2 values. If I use spinners with more steps, 1 second intervals also seem to skip steps.

If I change the delay to be time.Sleep(500 * time.Millisecond) it does work and I see all 4 steps, but my proposed usage would be at 1 second intervals. On the other hand, if I go to time.Sleep(2 * time.Second) I get no change in the spinner, although in all situations the count increments correctly.

Is there somewhere I need to set the "total time lapse" of a spinner rotation?

jazzboME avatar Oct 29 '22 19:10 jazzboME

would accept PR

schollz avatar May 20 '24 13:05 schollz