From dc3ef0a3bb1a1c0c7c0b1b2f47efec50807d9d66 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Sun, 22 Dec 2024 11:03:03 -0300 Subject: [PATCH] General command --- app/configs/commands.php | 2 ++ app/src/Command/Generate.php | 40 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 app/src/Command/Generate.php 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