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

a 0 total default to 100 #11

Closed
jfmmm opened this issue Aug 1, 2017 · 10 comments
Closed

a 0 total default to 100 #11

jfmmm opened this issue Aug 1, 2017 · 10 comments

Comments

@jfmmm
Copy link

jfmmm commented Aug 1, 2017

if you put 0 as the total it will show as 100 (sometime you don't want to change the logic but just happen to have nothing to insert in the db that particular time.)

var cliProgress = require("cli-progress")
const pb = new cliProgress.Bar();
pb.start(0, 0);

will show

progress [----------------------------------------] 0% | ETA: nulls | 0/100

instead of

progress [----------------------------------------] 0% | ETA: nulls | 0/0

@AndiDittrich
Copy link
Member

HI Jean,
thanks for your report. this behaviour is not intended...it is caused by some default values which take precedence in case the provided values are invalid (for example 0).

this.value = startValue || 0;
this.total = total || 100;

i could an an about condition like startValue===total to the .start() function which immediately returns in such cases.

what do you think ?

best regards, Andi

@jfmmm
Copy link
Author

jfmmm commented Aug 2, 2017

My issue is not that it doesn't return tho. I can just call stop() myself, it's not a problem.

The problem to me is that it instantly skip thought this progress bar without marking it as completed and when you look at what was logged you see 0/100 and wonder why it did nothing while there was 100 items. You think there was a problem while really everything worked as planned.

I fixed it for now by enabling clearOnComplete but I would have rather keep them in the log and just show 0/0.

Wouldn't it be simple to just change that one line of code?

this.value = (typeof startValue !== undefined) ? startValue : 100;

or something similar.

Thanks!

@AndiDittrich
Copy link
Member

thats a good, suggestion! i think we can do this without any backward compatibility issue.

@AndiDittrich
Copy link
Member

please try the latest version from the master branch.

@jfmmm
Copy link
Author

jfmmm commented Aug 2, 2017

Oh wow glad you got it despite that ridiculous line of code I wrote.. Never write code in a rush before a meeting. Wasn't even the right value haha.

Anyway I just tried it and it work perfectly. It even get completed when I call .stop().

Thanks and have a 🌠 for your trouble :)

@jfmmm
Copy link
Author

jfmmm commented Aug 18, 2017

You plan on releasing the new version when? seem like haven't done that in a while, the official one is still 1.3.0.

@AndiDittrich
Copy link
Member

HI Jean,

thats not correct. The GitHub as well as the related NPM release are pointed to v1.4.1 (since 4 month).

I will release v1.5.0 today :)

@jfmmm
Copy link
Author

jfmmm commented Aug 21, 2017

On github it seem the latest version is still 1.3.0 no? or am I misreading this.
http://i.imgur.com/kp1kNbW.png

Anyway npm is updated and that's all I needed, thanks!

@AndiDittrich
Copy link
Member

Click on show 4 newer tags on the top of the last drafted release

@erikkallen
Copy link
Contributor

This issue still remains in 1.5.0 because of this line 7605d2c#diff-cd4284509ea6de13aeaac4abc9e81bbdR75 please reopen this issue

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

No branches or pull requests

3 participants