Ejemplo n.º 1
0
 /**
  * Method to call another console command
  *
  * @param   string  $class      The command to call
  * @param   string  $task       The command task to call
  * @param   object  $arguments  The command arguments
  * @param   object  $output     The command output
  * @return  void
  */
 public function call($class, $task, Arguments $arguments, Output $output)
 {
     // Namespace class
     $class = Arguments::routeCommand($class);
     // Say no to infinite nesting!
     $backtrace = debug_backtrace();
     $previous = $backtrace[1];
     $prevClass = $previous['class'];
     $prevTask = $previous['function'];
     if ($prevClass == $class && $prevTask == $task) {
         $output->error('You\'ve attempted to enter an infinite loop. We\'ve stopped you. You\'re welcome.');
     }
     // If task is help, set the output to our output class with extra methods for rendering help doc
     if ($task == 'help') {
         $output = $output->getHelpOutput();
     }
     $command = new $class($output, $arguments);
     $command->{$task}();
 }
Ejemplo n.º 2
0
 /**
  * Show current output format
  *
  * @param   \Hubzero\Console\Output  $output  The output object
  * @return  void
  **/
 public static function format($output)
 {
     $output->addString('The profile log has the following format (');
     $output->addString('* indicates visible field', array('color' => 'blue'));
     $output->addLine('):');
     $i = 0;
     foreach (static::$fields as $field => $status) {
         if ($i != 0) {
             $output->addString(' ');
         }
         $output->addString('<');
         if ($i < 10) {
             $output->addString($i . ':');
         }
         if ($status) {
             $output->addString('*' . $field, array('color' => 'blue'));
         } else {
             $output->addString($field);
         }
         $output->addString('>');
         $i++;
     }
     $output->addSpacer()->addSpacer();
 }
Ejemplo n.º 3
0
 /**
  * Tests to make sure we can output a cool table
  *
  * @return  void
  **/
 public function testOutputTable()
 {
     $output = new Output();
     $actual = $this->getBuffered(function () use($output) {
         $table = [];
         $table[] = ['John', 'Football'];
         $table[] = ['Stephen', 'Soccer'];
         $table[] = ['Ben', 'Baseball'];
         $output->addTable($table);
     });
     $expected = '\\033[0m/--------------------\\\\033[0m\\n';
     $expected .= '\\033[0m| \\033[0m\\033[0mJohn\\033[0m\\033[0m    \\033[0m\\033[0m| \\033[0m\\033[0mFootball\\033[0m\\033[0m \\033[0m\\033[0m|\\033[0m\\n';
     $expected .= '\\033[0m| \\033[0m\\033[0mStephen\\033[0m\\033[0m \\033[0m\\033[0m| \\033[0m\\033[0mSoccer\\033[0m\\033[0m   \\033[0m\\033[0m|\\033[0m\\n';
     $expected .= '\\033[0m| \\033[0m\\033[0mBen\\033[0m\\033[0m     \\033[0m\\033[0m| \\033[0m\\033[0mBaseball\\033[0m\\033[0m \\033[0m\\033[0m|\\033[0m\\n';
     $expected .= '\\033[0m\\--------------------/\\033[0m\\n';
     $this->assertEquals($expected, $actual, 'Output did not have the expected table');
 }