-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] add overwrite flag to ProgressBar helper to allow non-decorated output #11852
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
Conversation
it would be good to add a test using |
Done, good catch. |
* | ||
* @param bool $overwrite | ||
*/ | ||
public function setOverwrite($overwrite = true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not provide a default value for the argument.
btw, the windows cmd shell supports the overwriting sequence, while it does not support colors (it requires wrapping it in ConEmu or Ansicon to get color support). would it make sense to tweak a bit the default value of |
hmm, what would we do if someone used the |
Anything preventing this from making it into 2.6? |
👍 |
Thank you @kbond. |
…allow non-decorated output (kbond) This PR was merged into the 2.6-dev branch. Discussion ---------- [Console] add overwrite flag to ProgressBar helper to allow non-decorated output | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | yes, but not critical | Deprecations? | no | Tests pass? | yes | Fixed tickets | #11542, #10011 | License | MIT | Doc PR | symfony/symfony-docs#4206 By default, the `ProgressBar` helper overwrites the output to give the nice progress bar look. To prevent the output from blowing up in non-decorated environments, the output was hidden in these environments (see #9846). This PR enables using the `ProgressBar` in non-decorated environments by adding an `overwrite` flag. When `false`, instead of overwriting the bar, it is rendered on a new line. To prevent flooding the output, you can adjust the `redrawFrequency`. By default, when using the `ProgressBar` in a non-decorated environment, the `overwrite` flag is set to false. If a `max` is set, the `redrawFrequency` is set to a sensible default (10% of the max). If a `max` isn't set, the bar is output for every advance so to prevent flooding, a sensible `redrawFrequency` should be manually set. The only BC break is that output will now display where it didn't before. Commits ------- cdee6f6 add overwrite flag to allow non-decorated output
This PR was merged into the master branch. Discussion ---------- Added note about ProgressBar changes | Q | A | ------------- | --- | Doc fix? | no | New docs? | symfony/symfony#11852 | Applies to | 2.6 | Fixed tickets | n/a Commits ------- 4e2142d Added note about ProgressBar changes
By default, the
ProgressBar
helper overwrites the output to give the nice progress bar look. To prevent the output from blowing up in non-decorated environments, the output was hidden in these environments (see #9846).This PR enables using the
ProgressBar
in non-decorated environments by adding anoverwrite
flag. Whenfalse
, instead of overwriting the bar, it is rendered on a new line. To prevent flooding the output, you can adjust theredrawFrequency
.By default, when using the
ProgressBar
in a non-decorated environment, theoverwrite
flag is set to false. If amax
is set, theredrawFrequency
is set to a sensible default (10% of the max). If amax
isn't set, the bar is output for every advance so to prevent flooding, a sensibleredrawFrequency
should be manually set.The only BC break is that output will now display where it didn't before.