diff options
author | Fbenas <philbeansburton@gmail.com> | 2020-06-14 20:47:59 +0100 |
---|---|---|
committer | Fbenas <philbeansburton@gmail.com> | 2020-06-14 20:47:59 +0100 |
commit | dedad998594fcfc2816f59c190c221a7c4504da7 (patch) | |
tree | b76d1fb765ad7bc6c84496513f43bfbcdb442867 | |
parent | b82f2c74d1fdb0e0aaaa4c93a2a904e376b310a2 (diff) |
Allow adding multiple commands
-rw-r--r-- | src/Application.php | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/Application.php b/src/Application.php index 88843ac..05f5c0f 100644 --- a/src/Application.php +++ b/src/Application.php @@ -29,7 +29,7 @@ abstract class Application // or return this if some error happened during the execution // (it's equivalent to returning int(1)) // return Command::FAILURE; - abstract protected function command(): Command; + abstract protected function commands(): Array; public function fromArgv() { @@ -73,11 +73,13 @@ abstract class Application public function run() { $this->application = new SymfonyApplication(); - $command = $this->command(); + $commands = $this->commands(); - $this->application->add($command); - $this->application->setDefaultCommand($command->getName()); - $this->application->run($this->input, $this->output); + foreach ($commands as $command) { + $this->application->add($command); + $this->application->setDefaultCommand($command->getName()); + $this->application->run($this->input, $this->output); + } } protected function readStdin() |