protected function getDevelopmentCommands() { if (!class_exists('TaskFile')) { return []; } $commands = []; $tasks = new TaskFile(); $runner = new Runner(); Config::setOutput(new ConsoleOutput()); $commandNames = array_filter(get_class_methods($tasks), function ($m) { return strpos($m, '__') === false; }); foreach ($commandNames as $commandName) { $command = $runner->createCommand(new TaskInfo('TaskFile', $commandName)); $command->setCode(function (InputInterface $input) use($tasks, $commandName) { // get passthru args $args = $input->getArguments(); array_shift($args); $args[] = $input->getOptions(); $res = call_user_func_array([$tasks, $commandName], $args); if (is_int($res)) { exit($res); } if (is_bool($res)) { exit($res ? 0 : 1); } if ($res instanceof Result) { exit($res->getExitCode()); } }); $commands[] = $command; } return $commands; }
protected function createCommand($name) { return $this->runner->createCommand(new \Robo\TaskInfo(self::ROBOFILE, $name)); }