Skip to content

Commit 5607d45

Browse files
committed
[feat] implement database commands ConfirmableCommand
1 parent f446a93 commit 5607d45

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

src/Commands/BaseCommand.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ public function getInfo(): ?string
6161

6262
public function getConfirmableLabel(): ?string
6363
{
64-
return 'Warning';
64+
return 'Application In Production';
65+
}
66+
67+
public function getConfirmableCallback(): \Closure|bool|null
68+
{
69+
return null;
6570
}
6671

6772
/**
@@ -71,8 +76,8 @@ public function handle()
7176
{
7277
if ($this instanceof ConfirmableCommand) {
7378
if ($this->isProhibited() ||
74-
! $this->confirmToProceed($this->getConfirmableLabel(), fn () => true)) {
75-
return 1;
79+
! $this->confirmToProceed($this->getConfirmableLabel(), $this->getConfirmableCallback())) {
80+
return Command::FAILURE;
7681
}
7782
}
7883

src/Commands/Database/MigrateFreshCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
use Illuminate\Database\Migrations\Migrator;
66
use Illuminate\Support\Collection;
77
use Nwidart\Modules\Commands\BaseCommand;
8+
use Nwidart\Modules\Contracts\ConfirmableCommand;
89
use Symfony\Component\Console\Input\InputOption;
910

10-
class MigrateFreshCommand extends BaseCommand
11+
class MigrateFreshCommand extends BaseCommand implements ConfirmableCommand
1112
{
1213
/**
1314
* The console command name.

src/Commands/Database/MigrateRefreshCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
namespace Nwidart\Modules\Commands\Database;
44

55
use Nwidart\Modules\Commands\BaseCommand;
6+
use Nwidart\Modules\Contracts\ConfirmableCommand;
67
use Symfony\Component\Console\Input\InputOption;
78

8-
class MigrateRefreshCommand extends BaseCommand
9+
class MigrateRefreshCommand extends BaseCommand implements ConfirmableCommand
910
{
1011
/**
1112
* The console command name.

src/Commands/Database/MigrateResetCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
namespace Nwidart\Modules\Commands\Database;
44

55
use Nwidart\Modules\Commands\BaseCommand;
6+
use Nwidart\Modules\Contracts\ConfirmableCommand;
67
use Nwidart\Modules\Migrations\Migrator;
78
use Nwidart\Modules\Traits\MigrationLoaderTrait;
89
use Symfony\Component\Console\Input\InputOption;
910

10-
class MigrateResetCommand extends BaseCommand
11+
class MigrateResetCommand extends BaseCommand implements ConfirmableCommand
1112
{
1213
use MigrationLoaderTrait;
1314

0 commit comments

Comments
 (0)