diff --git a/src/SPC/command/DoctorCommand.php b/src/SPC/command/DoctorCommand.php index bf914f32..1db5e180 100644 --- a/src/SPC/command/DoctorCommand.php +++ b/src/SPC/command/DoctorCommand.php @@ -10,11 +10,16 @@ use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand('doctor', 'Diagnose whether the current environment can compile normally')] class DoctorCommand extends BaseCommand { + public function configure() + { + $this->addOption('auto-fix', null, null, 'Automatically fix failed items (if possible)'); + } + public function handle(): int { try { $checker = new CheckListHandler($this->input, $this->output); - $checker->runCheck(FIX_POLICY_PROMPT); + $checker->runCheck($this->input->getOption('auto-fix') ? FIX_POLICY_AUTOFIX : FIX_POLICY_PROMPT); $this->output->writeln('Doctor check complete !'); } catch (\Throwable $e) { $this->output->writeln('' . $e->getMessage() . '');