This commit is contained in:
Juan Pablo Vial
2024-12-21 19:00:07 -03:00
parent 18742b3947
commit 03f91bd721

View 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;
}
}