From 7cf6830cba0d717c04db31c6f86f1eb67dc7dbdc Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 20 Mar 2024 16:43:41 +0000 Subject: [PATCH 1/2] Adds `--bail` flag --- app/Actions/ElaborateSummary.php | 2 +- app/Commands/DefaultCommand.php | 1 + app/Factories/ConfigurationResolverFactory.php | 4 ++-- app/Output/Concerns/InteractsWithSymbols.php | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Actions/ElaborateSummary.php b/app/Actions/ElaborateSummary.php index f4613a9f..ae861378 100644 --- a/app/Actions/ElaborateSummary.php +++ b/app/Actions/ElaborateSummary.php @@ -41,7 +41,7 @@ public function execute($totalFiles, $changes) 0, 0, $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE, - $this->input->getOption('test'), + $this->input->getOption('test') || $this->input->getOption('bail'), $this->output->isDecorated() ); diff --git a/app/Commands/DefaultCommand.php b/app/Commands/DefaultCommand.php index 1c6bb71f..9bf94dff 100644 --- a/app/Commands/DefaultCommand.php +++ b/app/Commands/DefaultCommand.php @@ -35,6 +35,7 @@ protected function configure() ->setDefinition( [ new InputArgument('path', InputArgument::IS_ARRAY, 'The path to fix', [(string) getcwd()]), + new InputOption('bail', '', InputOption::VALUE_NONE, 'Test for code style errors without fixing them and stop on first error'), new InputOption('config', '', InputOption::VALUE_REQUIRED, 'The configuration that should be used'), new InputOption('no-config', '', InputOption::VALUE_NONE, 'Disable loading any configuration file'), new InputOption('preset', '', InputOption::VALUE_REQUIRED, 'The preset that should be used'), diff --git a/app/Factories/ConfigurationResolverFactory.php b/app/Factories/ConfigurationResolverFactory.php index 709c2dbb..37b140bb 100644 --- a/app/Factories/ConfigurationResolverFactory.php +++ b/app/Factories/ConfigurationResolverFactory.php @@ -54,7 +54,7 @@ public static function fromIO($input, $output) sprintf('%s.php', $preset), ]), 'diff' => $output->isVerbose(), - 'dry-run' => $input->getOption('test'), + 'dry-run' => $input->getOption('test') || $input->getOption('bail'), 'path' => $path, 'path-mode' => ConfigurationResolver::PATH_MODE_OVERRIDE, 'cache-file' => $input->getOption('cache-file') ?? $localConfiguration->cacheFile() ?? implode(DIRECTORY_SEPARATOR, [ @@ -65,7 +65,7 @@ public static function fromIO($input, $output) : (string) microtime() ), ]), - 'stop-on-violation' => false, + 'stop-on-violation' => $input->getOption('bail'), 'verbosity' => $output->getVerbosity(), 'show-progress' => 'true', ], diff --git a/app/Output/Concerns/InteractsWithSymbols.php b/app/Output/Concerns/InteractsWithSymbols.php index 4feea45e..a1f5ff78 100644 --- a/app/Output/Concerns/InteractsWithSymbols.php +++ b/app/Output/Concerns/InteractsWithSymbols.php @@ -39,7 +39,7 @@ public function getSymbol($status) $statusSymbol = $this->statuses[$status]; if (! isset($statusSymbol['symbol'])) { - $statusSymbol = $this->input->getOption('test') + $statusSymbol = ($this->input->getOption('test') || $this->input->getOption('bail')) ? $statusSymbol[0] : $statusSymbol[1]; } From ddca3b6be99131a6ea87ef7d19ad210de75a83ce Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 20 Mar 2024 14:06:48 -0600 Subject: [PATCH 2/2] Update DefaultCommand.php --- app/Commands/DefaultCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Commands/DefaultCommand.php b/app/Commands/DefaultCommand.php index 9bf94dff..5c6e1002 100644 --- a/app/Commands/DefaultCommand.php +++ b/app/Commands/DefaultCommand.php @@ -35,11 +35,11 @@ protected function configure() ->setDefinition( [ new InputArgument('path', InputArgument::IS_ARRAY, 'The path to fix', [(string) getcwd()]), - new InputOption('bail', '', InputOption::VALUE_NONE, 'Test for code style errors without fixing them and stop on first error'), new InputOption('config', '', InputOption::VALUE_REQUIRED, 'The configuration that should be used'), new InputOption('no-config', '', InputOption::VALUE_NONE, 'Disable loading any configuration file'), new InputOption('preset', '', InputOption::VALUE_REQUIRED, 'The preset that should be used'), new InputOption('test', '', InputOption::VALUE_NONE, 'Test for code style errors without fixing them'), + new InputOption('bail', '', InputOption::VALUE_NONE, 'Test for code style errors without fixing them and stop on first error'), new InputOption('dirty', '', InputOption::VALUE_NONE, 'Only fix files that have uncommitted changes'), new InputOption('format', '', InputOption::VALUE_REQUIRED, 'The output format that should be used'), new InputOption('cache-file', '', InputArgument::OPTIONAL, 'The path to the cache file'),