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

How to print text when bar is running? #110

Open
violarulan opened this issue Aug 5, 2017 · 5 comments
Open

How to print text when bar is running? #110

violarulan opened this issue Aug 5, 2017 · 5 comments

Comments

@violarulan
Copy link

Hello, thanks for your work.
I want to print some log when the progress bar is running. But I run in to trouble.

What I want to achieve:

some log 0
some log 1
some log 2
some log 3
some log 4
some log 5
some log 6
some log 7
some log 8
some log 9
 10 / 10 [=================================================] 100.00% 4s
The End!

I got this:

 0 / 10 [-----------------------------------------------------]   0.00%some log 0
 1 / 10 [====>---------------------------------------------]  10.00% 1ssome log 1
 2 / 10 [=========>----------------------------------------]  20.00% 2ssome log 2
 3 / 10 [==============>-----------------------------------]  30.00% 2ssome log 3
 4 / 10 [===================>------------------------------]  40.00% 2ssome log 4
 5 / 10 [========================>-------------------------]  50.00% 1ssome log 5
 6 / 10 [=============================>--------------------]  60.00% 1ssome log 6
 7 / 10 [==================================>---------------]  70.00% 1ssome log 7
 8 / 10 [=======================================>----------]  80.00% 0ssome log 8
 9 / 10 [============================================>-----]  90.00% 0ssome log 9
 10 / 10 [=================================================] 100.00% 4s
The End!

my code:

package main

import (
	"gopkg.in/cheggaaa/pb.v1"
	"time"
	"fmt"
)

func main() {
	count := 10
	bar := pb.StartNew(count)
	for i := 0; i < count; i++ {
		fmt.Println("some log", i)
		bar.Increment()
		time.Sleep(400 * time.Millisecond)
	}
	bar.FinishPrint("The End!")
}

have tested on Ubuntu 14.04 with zsh 5.0.2

is there any direction I can look for?

Thanks in advance!

@cheggaaa
Copy link
Owner

This behavior is not yet available and is difficult to implement.
But you can simply call bar.Prefix ("some log")

@cheggaaa
Copy link
Owner

Maybe later (in v2) I will make a similar feature with ability to set absolute bar position (top, bottom, etc.).

@101usb
Copy link

101usb commented Oct 2, 2018

Бро, все с нетерпением ждём этого нововведения!

@secoba
Copy link

secoba commented Feb 16, 2020

Bro, everyone is looking forward to this innovation!

@romanshuplov
Copy link

so, was it add to V3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants