Skip to content

[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

Merged
merged 1 commit into from
Sep 22, 2014
Merged

[Console] add overwrite flag to ProgressBar helper to allow non-decorated output #11852

merged 1 commit into from
Sep 22, 2014

Conversation

kbond
Copy link
Member

@kbond kbond commented Sep 4, 2014

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.

@stof
Copy link
Member

stof commented Sep 4, 2014

it would be good to add a test using clear in non-overwrite mode, to ensure it does not do weird stuff

@kbond
Copy link
Member Author

kbond commented Sep 4, 2014

Done, good catch.

*
* @param bool $overwrite
*/
public function setOverwrite($overwrite = true)
Copy link
Member

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.

@fabpot fabpot added the Console label Sep 5, 2014
@stof
Copy link
Member

stof commented Sep 5, 2014

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 overwrite for Windows ?

@kbond
Copy link
Member Author

kbond commented Sep 8, 2014

hmm, what would we do if someone used the --no-ansi flag on windows then?

@kbond
Copy link
Member Author

kbond commented Sep 21, 2014

Anything preventing this from making it into 2.6?

@fabpot
Copy link
Member

fabpot commented Sep 21, 2014

👍

@fabpot
Copy link
Member

fabpot commented Sep 22, 2014

Thank you @kbond.

@fabpot fabpot merged commit cdee6f6 into symfony:master Sep 22, 2014
fabpot added a commit that referenced this pull request Sep 22, 2014
…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
weaverryan added a commit to symfony/symfony-docs that referenced this pull request Oct 3, 2014
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants