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

[ProcessBar] live update elapsed time for processor bar #460

Closed
howieyuen opened this issue Mar 22, 2023 · 0 comments · Fixed by #500
Closed

[ProcessBar] live update elapsed time for processor bar #460

howieyuen opened this issue Mar 22, 2023 · 0 comments · Fixed by #500
Labels
proposal Proposal to add a new feature to pterm

Comments

@howieyuen
Copy link

howieyuen commented Mar 22, 2023

The elapsed time is never changed, just stuck at 3s.
I was wondering whether we can do a live update for elapsed time.

example code:

func main() {
	showcases := []string{
		"Run short time job 1",
		"Run short time job 2",
		"Run short time job 3",
		"Run long time job 4",
	}

	pb, _ := pterm.DefaultProgressbar.
		WithTotal(len(showcases)).
		WithWriter(os.Stdout).
		Start()
	for i, showcase := range showcases {
		pb.UpdateTitle(showcase)
		if i >= 3 {
			time.Sleep(5 * time.Second)
		} else {
			time.Sleep(1 * time.Second)
		}
		pterm.Success.WithWriter(os.Stdout).Println(showcase)
		pb.Increment()
	}
}

git record:

pb0

@howieyuen howieyuen added the proposal Proposal to add a new feature to pterm label Mar 22, 2023
@howieyuen howieyuen changed the title [ProcessBar] just like stuck when wait a long time job [ProcessBar] live update elapsed time for processor bar Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Proposal to add a new feature to pterm
Projects
None yet
1 participant