Skip to content

[Console][Progress Bar] Output progress in --no-ansi #11542

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

Closed
tomzx opened this issue Aug 1, 2014 · 4 comments
Closed

[Console][Progress Bar] Output progress in --no-ansi #11542

tomzx opened this issue Aug 1, 2014 · 4 comments
Labels

Comments

@tomzx
Copy link

tomzx commented Aug 1, 2014

Hi,

We use the progress bar console component to display progress in one of our command that takes a while to execute. Sadly, when this command is executed during continuous integration (jenkins), no progress is displayed.

Based on the reading I've had on the subject (#9511 #10011), I understand it was decided not to display anything if --no-ansi is set/detected.

Is this assertion correct? If so, is there any way to use the progress bar component to display some form of progress for applications such as jenkins which most likely do not support overwriting sequence characters?

Thanks!

Note: --no-ansi is not passed to the console when executing said command.

@stof
Copy link
Member

stof commented Aug 18, 2014

If your application does not support the overwriting sequence char, the output of the progress bar will be completely broken (each display of the progress bar will be appended to the output instead of replacing the previous one). This is why it is disabled.

The disabling is based on the color support detection, which was the best choice we could make without adding a separate option for the output (which would not have been BC), even if Windows can actually support the overwriting sequence without supporting color sequences.

@stof stof added the Console label Aug 18, 2014
@tomzx
Copy link
Author

tomzx commented Aug 18, 2014

@stof, do you think it would be of any use to display some form of progress even in those cases? Something small such as

0%
5%
10%
....
100%

where each interval of progress is displayed on a new line (which should be supported everywhere). The best, in my opinion, would be to display the text part of the progress bar, with each increment on a new line.

0/3 0% 1 sec/1 sec 1.0 MB
1/3 33% 1 sec/1 sec 1.0 MB
3/3 100% 1 sec/1 sec 1.0 MB

It would possibly necessitate to define some value for that increment so that not every call to advance is rendered (such as the redraw frequency).

@kbond
Copy link
Member

kbond commented Sep 4, 2014

I am also interested in this - especially @tomzx's increment value idea.

For instance, if you set the increment value to 50 and your max is 200 your output would be (not overridden):

0/200 0% 1 sec/1 sec 1.0 MB
50/200 25% 1 sec/1 sec 1.0 MB
100/200 50% 1 sec/1 sec 1.0 MB
150/200 75% 1 sec/1 sec 1.0 MB
200/200 100% 1 sec/1 sec 1.0 MB

For a job that takes several minutes to run in a non-decorated environment (such as jenkins) it would be nice to see something... Not sure if the ProgressBar helper is the place for something like this or if it should be a new helper.

@kbond
Copy link
Member

kbond commented Sep 4, 2014

Tried my hand at a possible solution here #11852

fabpot added a commit that referenced this issue 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
@fabpot fabpot closed this as completed Sep 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants