General command
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
return [
|
||||
'commands' => [
|
||||
ProVM\Command\Generate::class,
|
||||
ProVM\Command\GenerateMigrations::class,
|
||||
ProVM\Command\GenerateSeeds::class,
|
||||
]
|
||||
];
|
40
app/src/Command/Generate.php
Normal file
40
app/src/Command/Generate.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace ProVM\Command;
|
||||
|
||||
use Symfony\Component\Console;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
#[Console\Attribute\AsCommand(name: 'generate', description: 'Generate database migrations and seeds.')]
|
||||
class Generate extends Console\Command\Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
$this->addOption('dry-run', 'd');
|
||||
}
|
||||
public function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new Console\Style\SymfonyStyle($input, $output);
|
||||
$io->title('Generate');
|
||||
|
||||
$dryRun = $input->hasOption('dry-run');
|
||||
|
||||
$commands = [
|
||||
'generate:migrations',
|
||||
'generate:seeds'
|
||||
];
|
||||
foreach ($commands as $commandName) {
|
||||
$command = $this->getApplication()->find($commandName);
|
||||
$arguments = [
|
||||
'command' => $commandName,
|
||||
];
|
||||
if ($dryRun) {
|
||||
$arguments['--dry-run'] = true;
|
||||
}
|
||||
$command->run(new Console\Input\ArrayInput($arguments), $output);
|
||||
}
|
||||
|
||||
return Console\Command\Command::SUCCESS;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user