Skip to content

Commit

Permalink
Merge pull request #215 from andreaswolf/add-dry-run-short
Browse files Browse the repository at this point in the history
[FEATURE] Add short notation for dry-run like Rector
  • Loading branch information
simonschaufi authored Aug 28, 2024
2 parents 4b91da7 + 09a7deb commit 567621e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/fractor/src/Configuration/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ final class Option
*/
public const DRY_RUN = 'dry-run';

/**
* @var string
*/
public const DRY_RUN_SHORT = 'n';

/**
* @var string
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/fractor/src/Console/Command/ProcessCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function configure(): void

$this->addOption(
Option::DRY_RUN,
null,
Option::DRY_RUN_SHORT,
InputOption::VALUE_NONE,
'Only see the diff of changes, do not save them to files.'
);
Expand Down
15 changes: 15 additions & 0 deletions packages/fractor/src/FractorApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace a9f\Fractor;

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputDefinition;

final class FractorApplication extends Application
{
Expand All @@ -16,4 +17,18 @@ public function __construct()
{
parent::__construct(self::NAME, self::FRACTOR_CONSOLE_VERSION);
}

protected function getDefaultInputDefinition(): InputDefinition
{
$defaultInputDefinition = parent::getDefaultInputDefinition();
$this->removeUnusedOptions($defaultInputDefinition);
return $defaultInputDefinition;
}

private function removeUnusedOptions(InputDefinition $inputDefinition): void
{
$options = $inputDefinition->getOptions();
unset($options['quiet'], $options['no-interaction']);
$inputDefinition->setOptions($options);
}
}

0 comments on commit 567621e

Please sign in to comment.