Skip to content

Commit 6bef414

Browse files
Add option to force environment and database deletion (#169)
* Added --force option to both database:delete and env:delete for automations * Update DatabaseDeleteCommand.php * Update EnvDeleteCommand.php * Update EnvDeleteCommand.php Co-authored-by: Taylor Otwell <[email protected]>
1 parent 0648b32 commit 6bef414

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Commands/DatabaseDeleteCommand.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Laravel\VaporCli\Helpers;
66
use Symfony\Component\Console\Input\InputArgument;
7+
use Symfony\Component\Console\Input\InputOption;
78

89
class DatabaseDeleteCommand extends Command
910
{
@@ -17,6 +18,7 @@ protected function configure()
1718
$this
1819
->setName('database:delete')
1920
->addArgument('database', InputArgument::REQUIRED, 'The database name / ID')
21+
->addOption('force', false, InputOption::VALUE_NONE, 'Force deletion of the database without confirmation')
2022
->setDescription('Delete a database');
2123
}
2224

@@ -27,7 +29,9 @@ protected function configure()
2729
*/
2830
public function handle()
2931
{
30-
if (! Helpers::confirm('Are you sure you want to delete this database', false)) {
32+
$forceDeletion = $this->option('force', false);
33+
34+
if (! $forceDeletion && ! Helpers::confirm('Are you sure you want to delete this database', false)) {
3135
Helpers::abort('Action cancelled.');
3236
}
3337

src/Commands/EnvDeleteCommand.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Laravel\VaporCli\Helpers;
77
use Laravel\VaporCli\Manifest;
88
use Symfony\Component\Console\Input\InputArgument;
9+
use Symfony\Component\Console\Input\InputOption;
910

1011
class EnvDeleteCommand extends Command
1112
{
@@ -19,6 +20,7 @@ protected function configure()
1920
$this
2021
->setName('env:delete')
2122
->addArgument('environment', InputArgument::REQUIRED, 'The environment name')
23+
->addOption('force', false, InputOption::VALUE_NONE, 'Force deletion of the environment without confirmation')
2224
->setDescription('Delete an environment');
2325
}
2426

@@ -31,7 +33,9 @@ public function handle()
3133
{
3234
$environment = $this->argument('environment');
3335

34-
if (! Helpers::confirm("Are you sure you want to delete the [{$environment}] environment", false)) {
36+
$forceDeletion = $this->option('force', false);
37+
38+
if (! $forceDeletion && ! Helpers::confirm("Are you sure you want to delete the [{$environment}] environment", false)) {
3539
Helpers::abort('Action cancelled.');
3640
}
3741

0 commit comments

Comments
 (0)