-
Notifications
You must be signed in to change notification settings - Fork 48
quick start
Inhere edited this page Jan 11, 2019
·
4 revisions
如下,新建一个命令行入口文件。 就可以开始使用了
// file: examples/app use Inhere\Console\IO\Input; use Inhere\Console\IO\Output; $meta = [ 'name' => 'My Console App', 'version' => '1.0.2', ]; $input = new Input; $output = new Output; // 通常无需传入 $input $output ,会自动创建 $app = new \Inhere\Console\Application($meta, $input, $output); // 注册命令 $app->command('demo', function (Input $in, Output $out) { $cmd = $in->getCommand(); $out->info('hello, this is a test command: ' . $cmd); }); // ... ... // run $app->run();
然后在命令行里执行 php examples/app
, 立即就可以看到如下输出了:
Alone Commands
中的 demo 就是我们上面添加的命令
-
help
显示应用或命令的帮助信息。help COMMAND
可以显示指定命令的帮助信息 -
list
列出所有可用命令,不传入任何命令时,默认执行它。 -
version
显示当前console应用的版本信息
-
-h, --help
显示应用或命令的帮助信息 -
--debug
设置日志错误报告级别 -
--no-color
可以设置主动关闭颜色输出 -
-v, --version
显示当前console应用的版本信息