nvan/cli-plus
最新稳定版本:v1.0.0
Composer 安装命令:
composer create-project nvan/cli-plus
包简介
CLI Plus is a PHP little library to add colors and effects to CLI apps
README 文档
README
CLI Plus is a little PHP library that allows you to set colors and format to the text that's being output to the Terminal / Command Line.
This is useful if you make apps that run on Command Line and you want to make them look nicer.
It's based on the idea of how the console is used in C# or other languages.
How to use
First of all import the library via composer:
composer require nvan/cli-plus
Once you have installed the library:
use nvan\CliPlus\Console; Console::writeLine('Hello world!'); Console::write('This is on the next line!'); Console::write('But this is not!');
You can apply foreground (text) color, and background color doing:
use nvan\CliPlus\Colors; Console::setForegroundColor(Colors::White); Console::setBackgroundColor(Colors::Red); Console::write('This text is white with red background!');
And to apply styles do:
use nvan\CliPlus\Formats; Console::setFormat(Formats::Bold); Console::write('This text is bold!');
Formats and colors lists with examples are available at: https://misc.flogisoft.com/bash/tip_colors_and_formatting
Future updates
I'm planning to add some kind of user input processing, kind of nextInt, nextX(type) from Java.
Also, I want to implement some features like reading passwords while the text is hidden (a little linux-style), even tough this can be done, but not as simple as it'll be with next updates, by doing something like:
Console::write('Enter your password: '); Console::addFormat(Formats::Hidden); Console::write(); $pass = readline(); Console::removeFormat(Formats::Hidden); if($pass === '12345') { Console::setForegroundColor(Colors::LightGreen); Console::writeLine('Password is correct! Welcome!'); }
Donations
If you use and like this library, consider buying me a 🍺 beer.
You can donate via PayPal:
License
MIT
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-11