/
ExamplesStyles.php
78 lines (68 loc) · 2.14 KB
/
ExamplesStyles.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* JBZoo Toolbox - Cli
*
* This file is part of the JBZoo Toolbox project.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Cli
* @license MIT
* @copyright Copyright (C) JBZoo.com, All rights reserved.
* @link https://github.com/JBZoo/Cli
*/
declare(strict_types=1);
namespace DemoApp\Commands;
use JBZoo\Cli\Cli;
use JBZoo\Cli\CliCommand;
use JBZoo\Cli\Codes;
/**
* Class ExamplesStyles
*/
class ExamplesStyles extends CliCommand
{
protected function configure(): void
{
$this
->setName('examples:styles')
->setDescription('Examples of new CLI colors and styles');
parent::configure();
}
/**
* @inheritDoc
*/
protected function executeAction(): int
{
// Render list of values
$this->_('Render list of values');
$this->_(Cli::renderList([
' Key' => 'Value',
' Key #2' => 123
], '-'));
/**
* Literally you can use the tags:
* - <color>Text</color>
* - <color-bold>Text</color-bold>
* - <color-under>Text</color-under>
* - <color-blink>Text</color-blink>
* - <color-bg>Text</color-bg>
*/
$this->_('Use different styles/colors to make terminal reading life easier');
$availableColors = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default'];
$listOfExamples = [];
foreach ($availableColors as $color) {
$listOfExamples[$color] = implode(' ', [
"<{$color}>Regular</{$color}>",
"<{$color}-bold>Bold</{$color}-bold>",
"<{$color}-under>Underlined</{$color}-under>",
"<{$color}-bg>Background</{$color}-bg>",
"<{$color}-blink>Blink</{$color}-blink>",
]);
}
$this->_(Cli::renderList($listOfExamples, '*'));
$this->_();
// Default success exist code is "0". Max value is 255.
// See JBZoo\Cli\Codes class for more info
return Codes::OK;
}
}