Skip to content

Commit

Permalink
Implement --no-diffs CLI Option (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Apr 19, 2024
1 parent ca60973 commit 1933073
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Configuration/ConfigurationFactory.php
Expand Up @@ -24,6 +24,7 @@ public function createFromInput(InputInterface $input): Configuration
$shouldClearCache = (bool) $input->getOption(Option::CLEAR_CACHE);
$showProgressBar = $this->canShowProgressBar($input);
$showErrorTable = ! (bool) $input->getOption(Option::NO_ERROR_TABLE);
$showDiffs = ! (bool) $input->getOption(Option::NO_DIFFS);
$parallelPort = (string) $input->getOption(Option::PARALLEL_PORT);
$parallelIdentifier = (string) $input->getOption(Option::PARALLEL_IDENTIFIER);

Expand All @@ -50,7 +51,8 @@ public function createFromInput(InputInterface $input): Configuration
$config,
$parallelPort,
$parallelIdentifier,
$memoryLimit
$memoryLimit,
$showDiffs
);
}

Expand Down
6 changes: 6 additions & 0 deletions src/Console/Command/AbstractCheckCommand.php
Expand Up @@ -40,6 +40,12 @@ protected function configure(): void
InputOption::VALUE_NONE,
'Hide error table. Useful e.g. for fast check of error count.'
);
$this->addOption(
Option::NO_DIFFS,
null,
InputOption::VALUE_NONE,
'Hide diffs of changed files. Useful e.g. for nicer CI output.'
);

$this->addOption(
Option::OUTPUT_FORMAT,
Expand Down
4 changes: 3 additions & 1 deletion src/Console/Output/ConsoleOutputFormatter.php
Expand Up @@ -30,7 +30,9 @@ public function __construct(
*/
public function report(ErrorAndDiffResult $errorAndDiffResult, Configuration $configuration): int
{
$this->reportFileDiffs($errorAndDiffResult->getFileDiffs());
if ($configuration->shouldShowDiffs()) {
$this->reportFileDiffs($errorAndDiffResult->getFileDiffs());
}

$this->easyCodingStandardStyle->newLine(1);

Expand Down
8 changes: 7 additions & 1 deletion src/ValueObject/Configuration.php
Expand Up @@ -22,7 +22,8 @@ public function __construct(
private ?string $config = null,
private string | null $parallelPort = null,
private string | null $parallelIdentifier = null,
private string | null $memoryLimit = null
private string | null $memoryLimit = null,
private bool $showDiffs = true
) {
}

Expand All @@ -46,6 +47,11 @@ public function shouldShowErrorTable(): bool
return $this->showErrorTable;
}

public function shouldShowDiffs(): bool
{
return $this->showDiffs;
}

/**
* @return string[]
*/
Expand Down
5 changes: 5 additions & 0 deletions src/ValueObject/Option.php
Expand Up @@ -31,6 +31,11 @@ final class Option
*/
public const OUTPUT_FORMAT = 'output-format';

/**
* @var string
*/
public const NO_DIFFS = 'no-diffs';

/**
* @api
* @deprecated Use @see \Symplify\EasyCodingStandard\Config\ECSConfig::skip()
Expand Down

0 comments on commit 1933073

Please sign in to comment.