Example #1
0
 function it_renders_output_according_to_processing_settings(IConsoleFormatter $formatter, IOutputBuffer $buffer)
 {
     $buffer->flush()->willReturn('text1');
     $this->setOutputFormat(OutputFormat::NORMAL);
     $formatter->formatAnsi('text1')->shouldBeCalled();
     $buffer->flush()->shouldBeCalled();
     $this->flushBuffer();
     $buffer->flush()->willReturn('text2');
     $this->setOutputFormat(OutputFormat::PLAIN);
     $formatter->formatPlain('text2')->shouldBeCalled();
     $buffer->flush()->shouldBeCalled();
     $this->flushBuffer();
     $buffer->flush()->willReturn('');
     $this->setOutputFormat(OutputFormat::RAW);
     $formatter->formatPlain('')->shouldNotBeCalled();
     $buffer->flush()->shouldBeCalled();
     $this->flushBuffer();
 }
Example #2
0
 /**
  * @param string $string
  *
  * @param null $format
  *
  * @return string
  */
 public function format($string, $format = null)
 {
     if ($format === null) {
         $format = $this->getOutputFormat();
     }
     // print output with ansi support
     if (($format & OutputFormat::NORMAL) === OutputFormat::NORMAL) {
         return $this->formatter->formatAnsi($string);
     } else {
         if (($format & OutputFormat::PLAIN) === OutputFormat::PLAIN) {
             return $this->formatter->formatPlain($string);
         }
     }
     // return raw output
     return $string;
 }
Example #3
0
 /**
  * Register default formatter styles.
  */
 protected function addDefaultStyles()
 {
     $this->consoleFormatter->style('error')->parseStyle('clr=white bg=red');
     $this->consoleFormatter->style('warning')->parseStyle('clr=black bg=yellow');
     $this->consoleFormatter->style('success')->parseStyle('clr=black bg=green');
     $this->consoleFormatter->style('question')->parseStyle('clr=green');
     $this->consoleFormatter->style('header')->parseStyle('clr=yellow');
     $this->consoleFormatter->style('title')->parseStyle('clr=yellow');
     $this->consoleFormatter->style('keyword')->parseStyle('clr=green');
     $this->consoleFormatter->style('green')->parseStyle('clr=green');
     $this->consoleFormatter->style('yellow')->parseStyle('clr=yellow');
     $this->consoleFormatter->style('red')->parseStyle('clr=red');
     $this->consoleFormatter->style('white')->parseStyle('clr=white');
     $this->consoleFormatter->style('blue')->parseStyle('clr=blue');
     $this->consoleFormatter->style('gray')->parseStyle('clr=gray');
     $this->consoleFormatter->style('black')->parseStyle('clr=black');
     $this->consoleFormatter->style('bold')->parseStyle('fmt=bold');
     $this->consoleFormatter->style('italic')->parseStyle('fmt=italic');
     $this->consoleFormatter->style('underline')->parseStyle('fmt=underline');
     $this->consoleFormatter->style('strikethrough')->parseStyle('fmt=strikethrough');
 }