mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-08 09:25:35 +08:00
add --auto-fix option
This commit is contained in:
@@ -10,11 +10,16 @@ use Symfony\Component\Console\Attribute\AsCommand;
|
|||||||
#[AsCommand('doctor', 'Diagnose whether the current environment can compile normally')]
|
#[AsCommand('doctor', 'Diagnose whether the current environment can compile normally')]
|
||||||
class DoctorCommand extends BaseCommand
|
class DoctorCommand extends BaseCommand
|
||||||
{
|
{
|
||||||
|
public function configure()
|
||||||
|
{
|
||||||
|
$this->addOption('auto-fix', null, null, 'Automatically fix failed items (if possible)');
|
||||||
|
}
|
||||||
|
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$checker = new CheckListHandler($this->input, $this->output);
|
$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('<info>Doctor check complete !</info>');
|
$this->output->writeln('<info>Doctor check complete !</info>');
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$this->output->writeln('<error>' . $e->getMessage() . '</error>');
|
$this->output->writeln('<error>' . $e->getMessage() . '</error>');
|
||||||
|
|||||||
Reference in New Issue
Block a user