コード例 #1
0
ファイル: ColorsTest.php プロジェクト: maximebf/consolekit
 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'));
 }
コード例 #2
0
ファイル: Console.php プロジェクト: maximebf/consolekit
 /**
  * @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;
     }
 }