mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 12:54:52 +08:00
use prompts to ask
This commit is contained in:
parent
98b906db40
commit
e637cce6f2
@ -8,8 +8,8 @@ use SPC\doctor\CheckListHandler;
|
|||||||
use SPC\doctor\CheckResult;
|
use SPC\doctor\CheckResult;
|
||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
use Symfony\Component\Console\Attribute\AsCommand;
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
|
||||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
use function Laravel\Prompts\confirm;
|
||||||
|
|
||||||
#[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
|
||||||
@ -49,9 +49,8 @@ class DoctorCommand extends BaseCommand
|
|||||||
throw new RuntimeException('Some check items can not be fixed !');
|
throw new RuntimeException('Some check items can not be fixed !');
|
||||||
case FIX_POLICY_PROMPT:
|
case FIX_POLICY_PROMPT:
|
||||||
if ($result->getFixItem() !== '') {
|
if ($result->getFixItem() !== '') {
|
||||||
$helper = new QuestionHelper();
|
$question = confirm('Do you want to fix it?');
|
||||||
$question = new ConfirmationQuestion('Do you want to fix it? [Y/n] ', true);
|
if ($question) {
|
||||||
if ($helper->ask($this->input, $this->output, $question)) {
|
|
||||||
$checker->emitFix($this->output, $result);
|
$checker->emitFix($this->output, $result);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException('You cancelled fix');
|
throw new RuntimeException('You cancelled fix');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user