mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 21:04:52 +08:00
32 lines
943 B
PHP
32 lines
943 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace SPC\command;
|
|
|
|
use SPC\doctor\CheckListHandler;
|
|
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($this->input->getOption('auto-fix') ? FIX_POLICY_AUTOFIX : FIX_POLICY_PROMPT);
|
|
$this->output->writeln('<info>Doctor check complete !</info>');
|
|
} catch (\Throwable $e) {
|
|
$this->output->writeln('<error>' . $e->getMessage() . '</error>');
|
|
pcntl_signal(SIGINT, SIG_IGN);
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
}
|