| Conditions | 5 |
| Paths | 4 |
| Total Lines | 34 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | public function run() |
||
| 25 | { |
||
| 26 | $arguments = $this->getTaskArguments(); |
||
| 27 | |||
| 28 | $bin = \realpath(__DIR__ . '/../../../' . $this->getConfig()->get('taskman.bin_dir') . '/taskman'); |
||
| 29 | |||
| 30 | if (false === $bin) { |
||
| 31 | throw new TaskException(__CLASS__, 'Unable to find the taskman binary'); |
||
| 32 | } |
||
| 33 | |||
| 34 | $taskExec = $this->taskExec($bin)->arg($arguments['command']); |
||
| 35 | |||
| 36 | $container = Robo::getContainer(); |
||
| 37 | |||
| 38 | /** @var \Robo\Application $app */ |
||
| 39 | $app = $container->get('application'); |
||
| 40 | |||
| 41 | /** @var \Consolidation\AnnotatedCommand\AnnotatedCommand $command */ |
||
| 42 | $command = $app->get($arguments['command']); |
||
| 43 | $commandOptions = $command->getDefinition()->getOptions(); |
||
| 44 | |||
| 45 | // Propagate any input option passed to the child command. |
||
| 46 | foreach ($arguments['options'] as $name => $values) { |
||
| 47 | if (!isset($commandOptions[$name])) { |
||
| 48 | continue; |
||
| 49 | } |
||
| 50 | |||
| 51 | // But only if the called command has this option. |
||
| 52 | foreach ((array) $values as $value) { |
||
| 53 | $taskExec->option($name, $value); |
||
| 54 | } |
||
| 55 | } |
||
| 56 | |||
| 57 | return $taskExec->run(); |
||
| 58 | } |
||
| 60 |