Skip to content

Commit

Permalink
[feat] implement database commands ConfirmableCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
alissn committed Dec 3, 2024
1 parent f446a93 commit 5607d45
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/Commands/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ public function getInfo(): ?string

public function getConfirmableLabel(): ?string
{
return 'Warning';
return 'Application In Production';
}

public function getConfirmableCallback(): \Closure|bool|null
{
return null;
}

/**
Expand All @@ -71,8 +76,8 @@ public function handle()
{
if ($this instanceof ConfirmableCommand) {
if ($this->isProhibited() ||
! $this->confirmToProceed($this->getConfirmableLabel(), fn () => true)) {
return 1;
! $this->confirmToProceed($this->getConfirmableLabel(), $this->getConfirmableCallback())) {
return Command::FAILURE;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/Commands/Database/MigrateFreshCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
use Illuminate\Database\Migrations\Migrator;
use Illuminate\Support\Collection;
use Nwidart\Modules\Commands\BaseCommand;
use Nwidart\Modules\Contracts\ConfirmableCommand;
use Symfony\Component\Console\Input\InputOption;

class MigrateFreshCommand extends BaseCommand
class MigrateFreshCommand extends BaseCommand implements ConfirmableCommand
{
/**
* The console command name.
Expand Down
3 changes: 2 additions & 1 deletion src/Commands/Database/MigrateRefreshCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
namespace Nwidart\Modules\Commands\Database;

use Nwidart\Modules\Commands\BaseCommand;
use Nwidart\Modules\Contracts\ConfirmableCommand;
use Symfony\Component\Console\Input\InputOption;

class MigrateRefreshCommand extends BaseCommand
class MigrateRefreshCommand extends BaseCommand implements ConfirmableCommand
{
/**
* The console command name.
Expand Down
3 changes: 2 additions & 1 deletion src/Commands/Database/MigrateResetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace Nwidart\Modules\Commands\Database;

use Nwidart\Modules\Commands\BaseCommand;
use Nwidart\Modules\Contracts\ConfirmableCommand;
use Nwidart\Modules\Migrations\Migrator;
use Nwidart\Modules\Traits\MigrationLoaderTrait;
use Symfony\Component\Console\Input\InputOption;

class MigrateResetCommand extends BaseCommand
class MigrateResetCommand extends BaseCommand implements ConfirmableCommand
{
use MigrationLoaderTrait;

Expand Down

0 comments on commit 5607d45

Please sign in to comment.