geekdevs/cli-highlighter
Composer 安装命令:
composer require geekdevs/cli-highlighter
包简介
Library which is used to colorize syntax of xml, yaml and json in console.
README 文档
README
This is a syntax highlighter library used to colorize output of xml, json and yaml formats to be displayed in command-line utilities.
Installation
composer require geekdevs/cli-highlighter
Usage
Use individual highlighters:
$highlighter = new JsonHighlighter($jsonOptions);
echo $highlighter->highlight($input);
$highlighter = new XmlHighlighter($xmlOptions);
echo $highlighter->highlight($input);
$highlighter = new YamlHighlighter($yamlOptions);
echo $highlighter->highlight($input);
Use helper service for multiple formats
$options = [
'json' => [
'keys' => 'magenta',
'values' => 'green',
'braces' => 'light_white',
],
'xml' => [
'elements' => 'yellow',
'attributes' => 'green',
'values' => 'green',
'innerText' => 'light_white',
'comments' => 'gray',
'meta' => 'yellow',
],
'yaml' => [
'separators' => 'blue',
'keys' => 'yellow',
'values' => 'light_white',
'comments' => 'gray',
],
];
$highlighter = new \CliHighlighter\Service\Highlighter($options);
echo $highlighter->highlight($input, 'json');
echo $highlighter->highlight($input, 'xml');
echo $highlighter->highlight($input, 'yaml');
Use as console tool
You can use vendor/bin/highlighter script with preconfigured colors for json, xml, yaml. Like this
vendor/bin/highlighter json < input.json
vendor/bin/highlighter xml < input.xml
vendor/bin/highlighter yaml < yaml.xml
Alternativelym you can pipe this command like so:
echo "<hello name=\"world\" />" | vendor/bin/highlighter xml
统计信息
- 总下载量: 319
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2019-03-18