joomla/joomla-framework — pull request #150 by elkuku (2013-05-07 05:21:06+00:00)
Title: Add colors to CLI applications

This will add the possibility to use colors in CLI applications.

**Disclaimer**: This has been inspired by reading the documentation of [symfony/console](http://symfony.com/doc/master/components/console/introduction.html) which has been copied almost verbatim to our [readme.md](https://github.com/elkuku/joomla-framework/blob/cli-application/src/Joomla/Application/README.md), included here for reference:
The code, however, is mine ;)

## Colors for CLI Applications

It is possible to use colors on an ANSI enabled terminal.

```php
// Green text
$this->out('foo');

// Yellow text
$this->out('foo');

// Black text on a cyan background
$this->out('foo');

// White text on a red background
$this->out('foo');
```

You can also create your own styles.

```php
use Joomla\Application\Cli\Colorstyle;

$style = new Colorstyle('yellow', 'red', array('bold', 'blink'));
$this->getOutput()->addStyle('fire', $style);
$this->out('foo');

```

Available foreground and background colors are: black, red, green, yellow, blue, magenta, cyan and white.

And available options are: bold, underscore, blink and reverse.

You can also set these colors and options inside the tagname:

```php
// Green text
$this->out('foo');

// Black text on a cyan background
$this->out('foo');

// Bold text on a yellow background
$this->out('foo');
```