diff --git a/app/configs/commands.php b/app/configs/commands.php index 55cae85..c1cea4a 100644 --- a/app/configs/commands.php +++ b/app/configs/commands.php @@ -1,6 +1,8 @@ [ + ProVM\Command\Generate::class, ProVM\Command\GenerateMigrations::class, + ProVM\Command\GenerateSeeds::class, ] ]; \ No newline at end of file diff --git a/app/src/Command/Generate.php b/app/src/Command/Generate.php new file mode 100644 index 0000000..11a1860 --- /dev/null +++ b/app/src/Command/Generate.php @@ -0,0 +1,40 @@ +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; + } +} \ No newline at end of file