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
Disable progress bar when not in an interactive terminal #45596
Comments
Interesting ; I'm used to do the same whenever the input is not interactive (not exactly what it means, agreed) or not decorated, but I recently stumbled upon https://twitter.com/rectorphp/status/1492135257356779528?s=20&t=GZLDX4J0EwZEDnLQtlctrg. So it seems some would like to keep such progress bars in their CI/crons output (with a lower redraw frequency)? Another possibility might be a |
A lower redraw frequency might be a great strategy, but it's significantly more complex and means you have some idea of how long the process is going to take. Having an explicit option does sound like a better, more backwards-compatible strategy (and is something I have been looking for in |
Maybe instead of a frequency a |
Reminds me of the |
I think a piece of the puzzle will be https://github.com/symfony/symfony/blob/6.1/src/Symfony/Component/Console/Output/NullOutput.php : it will allow avoiding many Regarding the definition of the symfony/src/Symfony/Component/Console/Application.php Lines 1042 to 1052 in 88497f2
While 🤔 note that if we set the default value of that option to |
Thank you for this suggestion. |
Yes. |
Yes please! |
Yes please. |
Yes, please :) |
This seems not a big deal to work around. $progress_bar = new ProgressBar($output->isDecorated() ? $output : new NullOutput()); Or in case you are using output style. $io = new SymfonyStyle($input, $output);
$progress_bar = $io->isDecorated() ? $io->createProgressBar() : new ProgressBar(new NullOutput()); And the most weird case when only $is_decorated = $output instanceof ConsoleOutputInterface && $output->getErrorOutput()->isDecorated();
$progress_bar = new ProgressBar($is_decorated ? $output : new NullOutput()); |
Thank you for this suggestion. |
Yes |
Just chiming in here, as our GitHub action job is failing because there's still progress bar output after the success message (and exit code?). So a
|
@sebastiaanluca rector has |
I don't know why I posted this in symfony/symfony 😆🫣 AND rector has that flag indeed. I think I need some sleep, apologies. |
Description
Progress bars are a great way to provide feedback to somebody using a Symfony command in a terminal. However, when running the same Symfony command in a cronjob, you will often get logs flooded by the output of the same progress bar. I found that in my case, checking for the
TERM
env variable seemed like a reliable way to do this, and I'm proposing this is done internally by Symfony, transparently.Example
Before
After
The text was updated successfully, but these errors were encountered: