mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-08 01:15:37 +08:00
v3 base
This commit is contained in:
34
src/StaticPHP/Command/DoctorCommand.php
Normal file
34
src/StaticPHP/Command/DoctorCommand.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace StaticPHP\Command;
|
||||
|
||||
use StaticPHP\Doctor\Doctor;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
#[AsCommand('doctor', 'Diagnose whether the current environment can compile normally')]
|
||||
class DoctorCommand extends BaseCommand
|
||||
{
|
||||
public function configure(): void
|
||||
{
|
||||
$this->addOption('auto-fix', null, InputOption::VALUE_OPTIONAL, 'Automatically fix failed items (if possible)', false);
|
||||
}
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$fix_policy = match ($this->input->getOption('auto-fix')) {
|
||||
'never' => FIX_POLICY_DIE,
|
||||
true, null => FIX_POLICY_AUTOFIX,
|
||||
default => FIX_POLICY_PROMPT,
|
||||
};
|
||||
$doctor = new Doctor($this->output, $fix_policy);
|
||||
if ($doctor->checkAll()) {
|
||||
$this->output->writeln('<info>Doctor check complete !</info>');
|
||||
return static::SUCCESS;
|
||||
}
|
||||
|
||||
return static::FAILURE;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user