vbauerster / mpb

multi progress bar for Go cli applications
The Unlicense
2.31k stars 123 forks source link

Be able to update decorator text #57

Closed nektro closed 4 years ago

nektro commented 4 years ago

Right now there is no way to update the bar title or any decorator text, only change their configs.

Additionally, decor.CBFunc takes no index, so you have no idea which decorating with Bar.TraverseDecorators.

vbauerster commented 4 years ago

Decorators like percentage and eta for example are meant to be fixed format. Do you want to have something like decor.Name but with ability to set any text while bar is rendering?

As for decor.CBFunc I don't see any reason why it should provide index.

nektro commented 4 years ago

image

sparing the bad function name, I have this to generate a bar and the request was so that I could something like the following and update the last decorator

image

nektro commented 4 years ago

if you're wondering "why create a Bar with a total of 1" it's because I have other methods with a similar utility

image

vbauerster commented 4 years ago

I did some refactoring. You can use Any decorator in order to update decorator's text when needed.

vbauerster commented 4 years ago

Also, refer to pattern used in on_complete.go. You can override any existing decorator by using that pattern.