From 8787d375bf8c862bc31df3e02d3d65beb9b1267f Mon Sep 17 00:00:00 2001 From: Dorian Villet Date: Fri, 10 Jan 2020 15:06:05 +0100 Subject: [PATCH] Add a --no-progress-bar option (inspired from ECS) for nicer CI output. --- src/Configuration/Configuration.php | 4 +++- src/Configuration/Option.php | 5 +++++ src/Console/Command/ProcessCommand.php | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Configuration/Configuration.php b/src/Configuration/Configuration.php index c2407329529c..dbf5f7a057fe 100644 --- a/src/Configuration/Configuration.php +++ b/src/Configuration/Configuration.php @@ -128,7 +128,9 @@ public function mustMatchGitDiff(): bool private function canShowProgressBar(InputInterface $input): bool { - return $input->getOption(Option::OPTION_OUTPUT_FORMAT) !== JsonOutputFormatter::NAME; + $noProgressBar = (bool) $input->getOption(Option::OPTION_NO_PROGRESS_BAR); + + return ! $noProgressBar && $input->getOption(Option::OPTION_OUTPUT_FORMAT) !== JsonOutputFormatter::NAME; } private function setRule(?string $rule): void diff --git a/src/Configuration/Option.php b/src/Configuration/Option.php index d132400d77bd..d32b633303c0 100644 --- a/src/Configuration/Option.php +++ b/src/Configuration/Option.php @@ -26,6 +26,11 @@ final class Option */ public const OPTION_OUTPUT_FORMAT = 'output-format'; + /** + * @var string + */ + public const OPTION_NO_PROGRESS_BAR = 'no-progress-bar'; + /** * @var string */ diff --git a/src/Console/Command/ProcessCommand.php b/src/Console/Command/ProcessCommand.php index 739f5178071c..2e7307f91a63 100644 --- a/src/Console/Command/ProcessCommand.php +++ b/src/Console/Command/ProcessCommand.php @@ -165,6 +165,13 @@ protected function configure(): void sprintf('Select output format: "%s".', implode('", "', $availableOutputFormatters)), ConsoleOutputFormatter::NAME ); + + $this->addOption( + Option::OPTION_NO_PROGRESS_BAR, + null, + InputOption::VALUE_NONE, + 'Hide progress bar. Useful e.g. for nicer CI output.' + ); } protected function execute(InputInterface $input, OutputInterface $output): int