Command
This commit is contained in:
34
app/src/Command/GenerateMigrations.php
Normal file
34
app/src/Command/GenerateMigrations.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
namespace ProVM\Command;
|
||||||
|
|
||||||
|
use Symfony\Component\Console;
|
||||||
|
use ProVM\Generator;
|
||||||
|
|
||||||
|
#[Console\Attribute\AsCommand(
|
||||||
|
name: 'generate:migrations'
|
||||||
|
)]
|
||||||
|
class GenerateMigrations extends Console\Command\Command
|
||||||
|
{
|
||||||
|
public function __construct(protected Generator\Migration $migrationGenerator, ?string $name = null)
|
||||||
|
{
|
||||||
|
parent::__construct($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function configure(): void
|
||||||
|
{
|
||||||
|
parent::configure();
|
||||||
|
$this->addOption('dry-run', 'd', Console\Input\InputOption::VALUE_OPTIONAL, default: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output): int
|
||||||
|
{
|
||||||
|
$io = new Console\Style\SymfonyStyle($input, $output);
|
||||||
|
$io->title('Generate Migrations');
|
||||||
|
|
||||||
|
$dryRun = $input->getOption('dry-run');
|
||||||
|
|
||||||
|
$this->migrationGenerator->generate($io, $dryRun);
|
||||||
|
|
||||||
|
return Console\Command\Command::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user