Skip to content

Commit fdcd44e

Browse files
committed
add color example
1 parent 3ee320a commit fdcd44e

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

example/colors.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
use jblond\cli\Cli;
4+
use jblond\cli\CliColors;
5+
6+
require '../src/jblond/cli/Cli.php';
7+
require '../src/jblond/cli/CliColors.php';
8+
$cli = new Cli();
9+
$colors = new CliColors();
10+
11+
$allForegroundColors = $colors->getForegroundColors();
12+
$allBackgroundColors = $colors->getBackgroundColors();
13+
14+
foreach ($allForegroundColors as $color) {
15+
foreach ($allBackgroundColors as $bgColor) {
16+
$cli->output(
17+
$colors->getColoredString($color . ' on ' . $bgColor, $color, $bgColor)
18+
);
19+
$cli->output($colors->getColoredString(' ', 'default', 'default'));
20+
}
21+
}

src/jblond/cli/CliColors.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ class CliColors {
1414
*/
1515
private $foregroundColors = array(
1616
'black' => '0;30',
17-
'dark_gray' => '1;30',
18-
'blue' => '0,34',
19-
'light_blue' => '1;34',
17+
'dark_gray' => '5;30',
18+
'red' => '1;31',
19+
'light_red' => '1;31',
2020
'green' => '0;32',
2121
'light_green' => '1;32',
22-
'cyan' => '0;36',
23-
'light_cyan' => '1;36',
24-
'red' => '0;31',
25-
'light_red' => '1;31',
26-
'purple' => '0;35',
27-
'light_purple' => '1;35',
2822
'brown' => '0;33',
2923
'yellow' => '1;33',
24+
'blue' => '0,34',
25+
'light_blue' => '1;34',
26+
'purple' => '0;35',
27+
'light_purple' => '1;35',
28+
'cyan' => '0;36',
29+
'light_cyan' => '1;36',
3030
'light_gray' => '0;37',
31-
'white' => '1;37'
31+
'white' => '1;37',
3232
);
3333

3434
/**
@@ -42,7 +42,7 @@ class CliColors {
4242
'blue' => '44',
4343
'magenta' => '45',
4444
'cyan' => '46',
45-
'light_gray' => '47'
45+
'light_gray' => '47',
4646
);
4747

4848
/**

0 commit comments

Comments
 (0)