From fd60e0e9adcb01036502d822df784c1ea3cd7416 Mon Sep 17 00:00:00 2001 From: Jess Archer Date: Sun, 27 Aug 2023 16:01:02 +1000 Subject: [PATCH 1/2] Use Laravel Prompts when available --- .../Concerns/InteractsWithDockerComposeServices.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Console/Concerns/InteractsWithDockerComposeServices.php b/src/Console/Concerns/InteractsWithDockerComposeServices.php index b93e4918..f384baa6 100644 --- a/src/Console/Concerns/InteractsWithDockerComposeServices.php +++ b/src/Console/Concerns/InteractsWithDockerComposeServices.php @@ -39,6 +39,14 @@ trait InteractsWithDockerComposeServices */ protected function gatherServicesWithSymfonyMenu() { + if (function_exists('\Laravel\Prompts\multiselect')) { + return \Laravel\Prompts\multiselect( + label: 'Which services would you like to install?', + options: $this->services, + default: ['mysql'], + ); + } + return $this->choice('Which services would you like to install?', $this->services, 0, null, true); } From 2d9dcd3dfd054c20f26fc84d7bd2832368013d28 Mon Sep 17 00:00:00 2001 From: Jess Archer Date: Sun, 27 Aug 2023 16:08:37 +1000 Subject: [PATCH 2/2] Formatting --- src/Console/AddCommand.php | 2 +- src/Console/Concerns/InteractsWithDockerComposeServices.php | 4 ++-- src/Console/InstallCommand.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Console/AddCommand.php b/src/Console/AddCommand.php index 36c2cc92..ac88c598 100644 --- a/src/Console/AddCommand.php +++ b/src/Console/AddCommand.php @@ -37,7 +37,7 @@ public function handle() } elseif ($this->option('no-interaction')) { $services = $this->defaultServices; } else { - $services = $this->gatherServicesWithSymfonyMenu(); + $services = $this->gatherServicesInteractively(); } if ($invalidServices = array_diff($services, $this->services)) { diff --git a/src/Console/Concerns/InteractsWithDockerComposeServices.php b/src/Console/Concerns/InteractsWithDockerComposeServices.php index f384baa6..10974980 100644 --- a/src/Console/Concerns/InteractsWithDockerComposeServices.php +++ b/src/Console/Concerns/InteractsWithDockerComposeServices.php @@ -33,11 +33,11 @@ trait InteractsWithDockerComposeServices protected $defaultServices = ['mysql', 'redis', 'selenium', 'mailpit']; /** - * Gather the desired Sail services using a Symfony menu. + * Gather the desired Sail services using an interactive prompt. * * @return array */ - protected function gatherServicesWithSymfonyMenu() + protected function gatherServicesInteractively() { if (function_exists('\Laravel\Prompts\multiselect')) { return \Laravel\Prompts\multiselect( diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index 5bc286e5..87ca9847 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -38,7 +38,7 @@ public function handle() } elseif ($this->option('no-interaction')) { $services = $this->defaultServices; } else { - $services = $this->gatherServicesWithSymfonyMenu(); + $services = $this->gatherServicesInteractively(); } if ($invalidServices = array_diff($services, $this->services)) {