Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Use Laravel Prompts when available #612

Merged
merged 2 commits into from
Aug 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Console/AddCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
12 changes: 10 additions & 2 deletions src/Console/Concerns/InteractsWithDockerComposeServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,20 @@ 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(
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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down