mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-24 19:53:14 +01:00
Add must-match-git-diff option
This commit is contained in:
parent
45a6df769f
commit
3b5432a5b1
@ -44,6 +44,11 @@ final class Configuration
|
||||
*/
|
||||
private $areAnyPhpRectorsLoaded = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $mustMatchGitDiff = false;
|
||||
|
||||
/**
|
||||
* Needs to run in the start of the life cycle, since the rest of workflow uses it.
|
||||
*/
|
||||
@ -51,6 +56,7 @@ final class Configuration
|
||||
{
|
||||
$this->isDryRun = (bool) $input->getOption(Option::OPTION_DRY_RUN);
|
||||
$this->hideAutoloadErrors = (bool) $input->getOption(Option::HIDE_AUTOLOAD_ERRORS);
|
||||
$this->mustMatchGitDiff = (bool) $input->getOption(Option::MUST_MATCH_GIT_DIFF);
|
||||
$this->showProgressBar = $this->canShowProgressBar($input);
|
||||
|
||||
$this->setRule($input->getOption(Option::OPTION_RULE));
|
||||
@ -115,6 +121,11 @@ final class Configuration
|
||||
$this->areAnyPhpRectorsLoaded = $areAnyPhpRectorsLoaded;
|
||||
}
|
||||
|
||||
public function mustMatchGitDiff(): bool
|
||||
{
|
||||
return $this->mustMatchGitDiff;
|
||||
}
|
||||
|
||||
private function canShowProgressBar(InputInterface $input): bool
|
||||
{
|
||||
return $input->getOption(Option::OPTION_OUTPUT_FORMAT) !== JsonOutputFormatter::NAME;
|
||||
|
@ -65,4 +65,9 @@ final class Option
|
||||
* @var string
|
||||
*/
|
||||
public const EXCLUDE_RECTORS_PARAMETER = 'exclude_rectors';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const MUST_MATCH_GIT_DIFF = 'must-match-git-diff';
|
||||
}
|
||||
|
@ -148,6 +148,13 @@ final class ProcessCommand extends AbstractCommand
|
||||
'Hide autoload errors for the moment.'
|
||||
);
|
||||
|
||||
$this->addOption(
|
||||
Option::MUST_MATCH_GIT_DIFF,
|
||||
null,
|
||||
InputOption::VALUE_NONE,
|
||||
'Execute only on file matching the git diff.'
|
||||
);
|
||||
|
||||
$this->addOption(Option::OPTION_RULE, 'r', InputOption::VALUE_REQUIRED, 'Run only this single rule.');
|
||||
|
||||
$availableOutputFormatters = $this->outputFormatterCollector->getNames();
|
||||
|
Loading…
x
Reference in New Issue
Block a user