public function init($input, $output, $appName = null, $appVersion = null) { // If we were not provided a container, then create one if (!Robo::hasContainer()) { Robo::createDefaultContainer($input, $output, $appName, $appVersion); // Automatically register a shutdown function and // an error handler when we provide the container. $this->installRoboHandlers(); } $app = Robo::application(); $this->registerRoboFileCommands($app); return $app; }
/** * @param null|\Symfony\Component\Console\Input\InputInterface $input * @param null|\Symfony\Component\Console\Output\OutputInterface $output * @param null|\Robo\Application $app * @param array[] $commandFiles * * @return int */ public function run($input = null, $output = null, $app = null, $commandFiles = []) { // Create default input and output objects if they were not provided if (!$input) { $input = new StringInput(''); } if (is_array($input)) { $input = new ArgvInput($input); } if (!$output) { $output = new \Symfony\Component\Console\Output\ConsoleOutput(); } $this->setInput($input); $this->setOutput($output); // If we were not provided a container, then create one if (!$this->getContainer()) { $container = Robo::createDefaultContainer($input, $output, $app); $this->setContainer($container); // Automatically register a shutdown function and // an error handler when we provide the container. $this->installRoboHandlers(); } if (!$app) { $app = Robo::application(); } if (!isset($commandFiles)) { $this->yell("Robo is not initialized here. Please run `robo init` to create a new RoboFile", 40, 'yellow'); $app->addInitRoboFileCommand($this->roboFile, $this->roboClass); $commandFiles = []; } $this->registerCommandClasses($app, $commandFiles); try { $statusCode = $app->run($input, $output); } catch (TaskExitException $e) { $statusCode = $e->getCode() ?: 1; } return $statusCode; }