From dedad998594fcfc2816f59c190c221a7c4504da7 Mon Sep 17 00:00:00 2001 From: Fbenas Date: Sun, 14 Jun 2020 20:47:59 +0100 Subject: Allow adding multiple commands --- src/Application.php | 12 +++++++----- 1 file 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() -- cgit v1.2.3