public function execute($input = null) { register_shutdown_function(array($this, 'shutdown')); set_error_handler(array($this, 'handleError')); Config::setOutput(new ConsoleOutput()); $input = $this->prepareInput($input ? $input : $_SERVER['argv']); Config::setInput($input); $app = new Application('Robo', self::VERSION); if (!$this->loadRoboFile()) { $this->yell("Robo is not initialized here. Please run `robo init` to create a new RoboFile", 40, 'yellow'); $app->addInitRoboFileCommand($this->roboFile, $this->roboClass); $app->run($input); return; } $app->addCommandsFromClass($this->roboClass, $this->passThroughArgs); $app->run($input); }
/** * @param null $input Input * @return int|void * @throws \Exception * * Run tg and return an error code */ public function run($input = null) { register_shutdown_function([$this, 'shutdown']); set_error_handler([$this, 'handleError']); if ($this->classCache->getCachePath() === null) { $this->classCache->setCachePath(__DIR__ . "/../.tg/"); } $hasCommandFile = $this->autoloadCommandFile(); $this->setupDevModes(); $this->input = $this->prepareInput($input ? $input : $_SERVER['argv']); //Load all our commands $commandLoader = new CommandLoader(); $this->loadLocalFile($commandLoader, $hasCommandFile); //Cwd project specific $this->loadCoreCommands($commandLoader); //Tg vendor and core if (!$this->coreDevMode) { //If we are developing in the core we dont want to load cwd vendors folder at all $this->loadLocalVendors($commandLoader); //Cwd vendor } if ($this->libDevMode) { //If we are developing a library we want to load the cwd source folder $this->loadLocalSrc($commandLoader); } //Set up the robo static config class :( Config::setInput($this->input); Config::setOutput($this->output); $this->app->setAutoExit(false); return $this->app->run($this->input, $this->output); }