function find_subcommand(&$args) { $command = array_shift($args); Utils\load_command($command); if (!isset($this->subcommands[$command])) { return false; } return $this->subcommands[$command]; }
public function run() { if (Terminus::is_test()) { return true; } if (empty($this->arguments)) { $this->arguments[] = 'help'; } // Load bundled commands early, so that they're forced to use the same // APIs as non-bundled commands. Utils\load_command($this->arguments[0]); if (isset($this->config['require'])) { foreach ($this->config['require'] as $path) { Utils\load_file($path); } } // Show synopsis if it's a composite command. $r = $this->find_command_to_run($this->arguments); if (is_array($r)) { list($command) = $r; if ($command->can_have_subcommands()) { $command->show_usage(); exit; } } // First try at showing man page if ('help' === $this->arguments[0] && isset($this->arguments[1])) { $this->_run_command(); } # Run the stinkin command! $this->_run_command(); }