-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDemoStyles.php
96 lines (83 loc) · 2.75 KB
/
DemoStyles.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?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.
*
* @license MIT
* @copyright Copyright (C) JBZoo.com, All rights reserved.
* @see https://github.com/JBZoo/Cli
*/
declare(strict_types=1);
namespace DemoApp\Commands;
use JBZoo\Cli\CliCommand;
use JBZoo\Cli\CliRender;
use function JBZoo\Cli\cli;
class DemoStyles extends CliCommand
{
protected function configure(): void
{
$this
->setName('styles')
->setDescription('Examples of new CLI colors and styles');
parent::configure();
}
protected function executeAction(): int
{
// Render list of values
cli('Render list of values');
cli(
CliRender::list([
'Like a title',
'Key' => 'Value',
'Key #2' => 123,
], '-'),
);
/**
* Literally you can use the tags:
* - <color>Text</color>
* - <color-b>Text</color-b>
* - <color-u>Text</color-ur>
* - <color-bl>Text</color-bl>
* - <color-bg>Text</color-bg>
* - <color-r>Text</color-r>.
*/
cli('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}-b>Bold</{$color}-b>",
"<{$color}-u>Underlined</{$color}-u>",
"<{$color}-bg>Background</{$color}-bg>",
"<{$color}-r>Reverse</{$color}-r>",
"<{$color}-bl>Blink</{$color}-bl>",
]);
}
cli(CliRender::list($listOfExamples, '*'));
cli('Shortcuts:');
cli(
CliRender::list([
'\<bl\>' => '<bl>Blink</bl>',
'\<b\>' => '<b>Bold</b>',
'\<u\>' => '<u>Underscore</u>',
'\<r\>' => '<r>Reverse</r>',
'\<bg\>' => '<bg>Background</bg>',
], '*'),
);
cli('Aliases:');
cli(
CliRender::list([
'\<i\>' => '<i>Alias for \<info\></i>',
'\<c\>' => '<c>Alias for \<commnet\></c>',
'\<q\>' => '<q>Alias for \<question\></q>',
'\<e\>' => '<e>Alias for \<error\></e>',
], '*'),
);
// Default success exist code is "0". Max value is 255.
return self::SUCCESS;
}
}