22
33简洁功能全面的php命令行应用库。提供控制台参数解析, 颜色风格输出, 用户信息交互, 特殊格式信息显示
44
5- - 命令行应用, 命令行的controller, command 解析运行
5+ - 命令行应用, 命令行的 ` controller ` , ` command ` 解析运行
66- 功能全面的命令行的选项参数解析
7- - 命令行中功能强大的 input/ output 管理、使用
7+ - 命令行中功能强大的 ` input ` , ` output ` 管理、使用
88- 消息文本的多种颜色风格输出支持
9- - 常用的特殊格式信息显示(panel, help-panel, table, title, list, progressBar)
10- - 常用的用户信息交互支持(select, confirm, ask)
9+ - 常用的特殊格式信息显示(` section ` , ` panel ` , ` padding ` , ` help-panel ` , ` table ` , ` title ` , ` list ` , ` progressBar ` )
10+ - 常用的用户信息交互支持(` select ` , ` confirm ` , ` ask/question ` )
1111- 命令方法注释自动解析(提取为参数 ` arguments ` 和 选项 ` options ` 等信息)
1212- 类似 ` symfony/console ` 的预定义参数定义支持(按位置赋予参数值)
1313
@@ -85,6 +85,15 @@ $app->run();
8585添加命令的方式有三种
8686
8787- 如上所示,使用闭包可以快速的添加一个简单的命令
88+
89+ ``` php
90+ $app->command('demo', function (Input $in, Output $out) {
91+ $cmd = $in->getCommand();
92+
93+ $out->info('hello, this is a test command: ' . $cmd);
94+ });
95+ ```
96+
8897- 通过继承 ` Inhere\Console\Command ` 添加独立命令
8998
9099``` php
@@ -121,7 +130,7 @@ use Inhere\Console\Controller;
121130 */
122131class HomeController extends Controller
123132{
124- const DESCRIPTION = 'default command controller. there are some command usage examples';
133+ protected static $description = 'default command controller. there are some command usage examples';
125134
126135 /**
127136 * this is a command's description message
@@ -143,7 +152,7 @@ class HomeController extends Controller
143152
144153命令组(eg ` HomeController ` ) 中的命令(eg: ` indexCommand ` )上注释是可被解析的。
145154
146- - 当你使用 ` php examples/app home -h ` 时,可以查看到 ` HomeController::indexCommand ` 的描述注释文本
155+ - 当你使用 ` php examples/app home -h ` 时,可以查看到 ` HomeController ` 的所有命令信息
147156- 当使用 ` php examples/app home/index -h ` 时,可以查看到关于 ` HomeController::indexCommand ` 更详细的信息。包括描述注释文本、` @usage ` 、` @example `
148157
149158> 小提示:注释里面同样支持带颜色的文本输出 ` eg: this is a command's description <info>message</info> `
0 commit comments