Exemple #1
0
 function find_subcommand(&$args)
 {
     $command = array_shift($args);
     Utils\loadCommand($command);
     if (!isset($this->subcommands[$command])) {
         return false;
     }
     return $this->subcommands[$command];
 }
Exemple #2
0
 public function testLoadCommand()
 {
     $command_name = 'auth';
     $file_name = TERMINUS_ROOT . '/php/Terminus/Commands/AuthCommand.php';
     Utils\loadCommand($command_name);
     $included_files = get_included_files();
     $is_included = array_search($file_name, $included_files) !== false;
     $this->assertTrue($is_included);
 }
Exemple #3
0
 /**
  * Runs the Terminus command
  *
  * @return void
  */
 public function run()
 {
     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\loadCommand($this->arguments[0]);
     if (isset($this->config['require'])) {
         foreach ($this->config['require'] as $path) {
             Utils\loadFile($path);
         }
     }
     try {
         // Show synopsis if it's a composite command.
         $r = $this->findCommandToRun($this->arguments);
         if (is_array($r)) {
             /** @var \Terminus\Dispatcher\RootCommand $command */
             list($command) = $r;
             if ($command->canHaveSubcommands()) {
                 $command->showUsage();
                 exit;
             }
         }
     } catch (TerminusException $e) {
         // Do nothing. Actual error-handling will be done by _runCommand
         $this->logger->debug($e->getMessage());
     }
     // First try at showing man page
     if ($this->arguments[0] == 'help' && isset($this->arguments[1])) {
         $this->_runCommand();
     }
     $this->_runCommand();
 }
Exemple #4
0
 public function run()
 {
     if (Terminus::isTest()) {
         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\loadCommand($this->arguments[0]);
     if (isset($this->config['require'])) {
         foreach ($this->config['require'] as $path) {
             Utils\loadFile($path);
         }
     }
     try {
         // 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;
             }
         }
     } catch (TerminusException $e) {
         // Do nothing. Actual error handling will be done by _runCommand
     }
     // First try at showing man page
     if ('help' === $this->arguments[0] && isset($this->arguments[1])) {
         $this->_runCommand();
     }
     # Run the stinkin command!
     $this->_runCommand();
 }