wp-cli / php-cli-tools

A collection of tools to help with PHP command line utilities
MIT License
673 stars 118 forks source link

Progress bar goes to new line under windows #132

Open marcovalloni opened 6 years ago

marcovalloni commented 6 years ago

The progressbar instead of updating the current row print a new row with the updated values.

To fix this I've found that can be esily fixed by changing into Bar.php line 58 from

$size = Shell::columns();

to

$size = Shell::columns() - 1;

If it was ok as I fix I can also make a pull request for it.

Currently I've not tested it under others OS.

schlessera commented 6 years ago

@marcovalloni That will probably break all other systems, though. You'd need to add this change conditionally for Windows only.

marcovalloni commented 6 years ago

Yes, that wasn't a problem at all, I'll add a check for windows.

But I'll make some other checks because there's the same problem also to notify\dot and notify\spinner that uses the Streams::out_padded method.

schlessera commented 6 years ago

@marcovalloni Did https://github.com/wp-cli/php-cli-tools/pull/131 actually fix this issue? Or is this still happening on Windows?

marcovalloni commented 6 years ago

I've to make additional researches for this bug, in general under windows everything that is rewriting the line goes to a new line. I don't have much time in the last period.

With this fix I've fixed only the progressbar but also spinner and dots have the same issue.

I think that was a problem with the fact that windows move the pointer to the new line when it reach the last character of the line instead of keeping the same line.