norwichtech/php-cli-colours

一个小型库,用于在 CLI 脚本中使用颜色

这个包的规范仓库似乎已经消失,因此该包已被冻结。

1.2.1 2017-09-27 12:07 UTC

This package is not auto-updated.

Last update: 2020-11-28 08:39:36 UTC


README

我喜欢我的 CLI 脚本有颜色,通过这个库,我希望能够实现这些颜色

示例用法

include 'BashColours.php';
$bashColours=new \NorwichTech\CLIColours\BashColours();

echo "I am writing a nice CLI script and ".$bashColours->formatString("BANG!", 'red')." I need exciting things to happen\n";

echo $bashColours->formatString("But now everything is fine and stuff",'default','green');

现在你可以使用大量的快捷函数来改变前景色

include 'BashColours.php';
$colour=new \NorwichTech\CLIColours\BashColours();

echo $colour->red("red")." and ".$colour->yellow("yellow")." and ".$colour->lightMagenta("pink")." and ".$colour->green("green")."...\n";

实现了这个列表中所有前景和背景颜色

http://misc.flogisoft.com/bash/tip_colors_and_formatting

将来会考虑添加加粗/斜体/闪烁等功能。