public function testColorize() { $this->assertEquals("[31mred[0m", Colors::colorize('red', Colors::RED)); $this->assertEquals("[1;31mred[0m", Colors::colorize('red', Colors::RED | Colors::BOLD)); $this->assertEquals("[43m[31mred[0m", Colors::colorize('red', Colors::RED, Colors::YELLOW)); $this->assertEquals("[31mred[0m", Colors::red('red')); }
/** * @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; } }