Ejemplo n.º 1
0
 public function testColorize()
 {
     $this->assertEquals("red", Colors::colorize('red', Colors::RED));
     $this->assertEquals("red", Colors::colorize('red', Colors::RED | Colors::BOLD));
     $this->assertEquals("red", Colors::colorize('red', Colors::RED, Colors::YELLOW));
     $this->assertEquals("red", Colors::red('red'));
 }
Ejemplo n.º 2
0
 /**
  * @param array $args
  * @return mixed Results of the command callback
  */
 public function run(array $argv = null)
 {
     try {
         if ($argv === null) {
             $argv = isset($_SERVER['argv']) ? array_slice($_SERVER['argv'], 1) : array();
         }
         list($args, $options) = $this->getOptionsParser()->parse($argv);
         if ($this->defaultCommand && $this->singleCommand) {
             return $this->execute($this->defaultCommand, $args, $options);
         }
         if (!count($args)) {
             if ($this->defaultCommand) {
                 $args[] = $this->defaultCommand;
             } else {
                 $this->textWriter->writeln(Colors::red("Missing command name"));
                 $args[] = $this->helpCommand;
             }
         }
         $command = array_shift($args);
         return $this->execute($command, $args, $options);
     } catch (\Exception $e) {
         $this->writeException($e);
         if ($this->exitOnException) {
             exit(1);
         }
         throw $e;
     }
 }