diff --git a/packages/ChangesReporting/Output/ConsoleOutputFormatter.php b/packages/ChangesReporting/Output/ConsoleOutputFormatter.php index ee16fc81e96..2bb34fe8605 100644 --- a/packages/ChangesReporting/Output/ConsoleOutputFormatter.php +++ b/packages/ChangesReporting/Output/ConsoleOutputFormatter.php @@ -34,13 +34,21 @@ public function __construct( public function report(ProcessResult $processResult, Configuration $configuration): void { + $errors = $processResult->getErrors(); + + // only show 100% when no errors + if ($errors === [] && $configuration->shouldShowProgressBar()) { + $this->rectorOutputStyle->progressFinish(); + } + + // show diff after progress bar if ($configuration->shouldShowDiffs()) { $this->reportFileDiffs($processResult->getFileDiffs()); } $this->reportErrors($processResult->getErrors()); - if ($processResult->getErrors() !== []) { + if ($errors !== []) { return; } diff --git a/src/Console/Output/RectorOutputStyle.php b/src/Console/Output/RectorOutputStyle.php index 808deca00a1..c7f5514bb5e 100644 --- a/src/Console/Output/RectorOutputStyle.php +++ b/src/Console/Output/RectorOutputStyle.php @@ -28,6 +28,11 @@ public function progressAdvance(int $step = 1): void $this->rectorConsoleOutputStyle->progressAdvance($step); } + public function progressFinish(): void + { + $this->rectorConsoleOutputStyle->progressFinish(); + } + public function error(string $message): void { $this->rectorConsoleOutputStyle->error($message); diff --git a/src/Console/Style/RectorConsoleOutputStyle.php b/src/Console/Style/RectorConsoleOutputStyle.php index a79d9267513..f58a4faf006 100644 --- a/src/Console/Style/RectorConsoleOutputStyle.php +++ b/src/Console/Style/RectorConsoleOutputStyle.php @@ -81,4 +81,15 @@ private function getProgressBar(): ProgressBar { return $this->progressBar ?? throw new RuntimeException('The ProgressBar is not started.'); } + + public function progressFinish(): void + { + // hide progress bar in tests + if (defined('PHPUNIT_COMPOSER_INSTALL')) { + return; + } + + $progressBar = $this->getProgressBar(); + $progressBar->finish(); + } } diff --git a/src/Contract/Console/OutputStyleInterface.php b/src/Contract/Console/OutputStyleInterface.php index 6bd00bb2953..aa02bd2435c 100644 --- a/src/Contract/Console/OutputStyleInterface.php +++ b/src/Contract/Console/OutputStyleInterface.php @@ -34,4 +34,6 @@ public function setVerbosity(int $level): void; public function progressStart(int $fileCount): void; public function progressAdvance(int $step = 1): void; + + public function progressFinish(): void; }