- Added color / formats management
This commit is contained in:
1 parent
d503628356
commit
32d5079559
11 files changed
+297
-2
No files matched your search
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Mcnd\CLI\Lib;
|
||||
|
||||
trait ColorMappingTrait
|
||||
{
|
||||
public static function mapFrom(string $name) : ? self
|
||||
{
|
||||
return [
|
||||
'black' => self::Black,
|
||||
'red' => self::Red,
|
||||
'green' => self::Green,
|
||||
'yellow' => self::Yellow,
|
||||
'blue' => self::Blue,
|
||||
'magenta' => self::Magenta,
|
||||
'cyan' => self::Cyan,
|
||||
'lightgray' => self::LightGray,
|
||||
'darkgray' => self::DarkGray,
|
||||
'lightred' => self::LightRed,
|
||||
'lightgreen' => self::LightGreen,
|
||||
'lightyellow' => self::LightYellow,
|
||||
'lightblue' => self::LightBlue,
|
||||
'lightmagenta' => self::LightMagenta,
|
||||
'lightcyan' => self::LightCyan,
|
||||
'white' => self::White,
|
||||
][$name] ?? null;
|
||||
}
|
||||
|
||||
public function output() : string
|
||||
{
|
||||
return "\e[{$this->value}m";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user