Colors are added to cli texts for different reasons. Mostly, they either provide quick information on a particular subject matter or they are used to keep console users alert and aware of responses obtained from running a particular command. They can also be used to separate different syntaxes to a particular command but the most important use of colors is that they make console texts more readable and easier to process.
Cli colors are added to text through the use of color codes. Each text is wrapped within its own color code, making it impossible to add colors within another color code whether as a combination of text colors or text background colors. This in other words mean that each text color must be defined separately for each texts. The available methods under these category are listed below:
Cli::color($text, $name, $spacing);
where:
$text : The text on which color should be applied
$name : The name of color to be applied. Options are [red|blue|green|yellow|cyan|purple]
$spcaing : An optional spacing format
Cli::danger($text, $spacing);
where:
$text : The text on which color should be applied
$spacing : An optional spacing format
Cli::warn($text, $spacing);
where:
$text : The text on which color should be applied
$spacing : An optional spacing format
Cli::alert($text, $spacing);
where:
$text : The text on which color should be applied
$spacing : An optional spacing format
Cli::valid($text, $spacing);
where:
$text : The text on which color should be applied
$spacing : An optional spacing format
bgColor()
and the color()
methods cannot be applied within each other but can only be applied separately on different texts.
Cli::bgColor($text, $name, $spacing);
where:
$text : The text on which color should be applied
$name : The background color name to be applied. Options: [white|black|red|green|blue|cyan|purple|yellow]
$spacing : An optional spacing format
Cli::bgDanger($text, $spacing);
where:
$text : The text on which background color should be applied
$spacing : An optional spacing format
Cli::warn($text, $spacing);
where:
$text : The text on which background color should be applied
$spacing : An optional spacing format
Cli::bgAlert($text, $spacing);
where:
$text : The text on which background color should be applied
$spacing : An optional spacing format
Cli::bgValid($text, $spacing);
where:
$text : The text on which background color should be applied
$spacing : An optional spacing format