Download the PHP package iry/cli without Composer
On this page you can find all versions of the php package iry/cli. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package cli
[中文] / English
简介
iry/Cli 可以简单实现 输出、输入、倒计时、绘制进度条、绘制表格、移动光标、清除屏幕、确认对话 等功能
可以轻松实现类似表单等输入功能:
如(input: stdin, 开关:confirm, select:select,radio:select单选模式, checkbox:select多选模式)
安装
使用方法
环境控制 【可选】
示例
标准输入
stdin($msg,$validator,$processor);//等待并获取用户输入的数据
参数 | 类型 | 说明 |
---|---|---|
$msg | string | 消息:等待用户输入前,输一条提示消息消息 |
$validator | false/callable | 验证器:用于验证用户输入的信息是否有效的方法 |
$processor | false/callable | 处理器:对用户输入的数据进行处理的方法 |
标准输出 output($msg,$styleType)
打印到屏幕 支持彩色文字
参数 | 说明 | |
---|---|---|
$msg | string/array | 消息:等待用户输入前,输一条提示消息消息 |
$styleType | string/array | error,info,comment,question,highlight,warning,[前景色,背景色] |
$msg数组模式可以设置复杂的彩色文字如下示例
示例
示例大致效果如下
这是一个测试:
这是一个测试:
这是一个测试:
这是一个测试
这是一个测试:
这是一个测试:
这是一个测试
确认对话
confirm($msg,$validator,$processor);//Cli中 确认对话
参数 | 说明 | |
---|---|---|
$msg | string | 消息:等待用户输入前,输一条提示消息消息 |
return | bool | true/false |
$msg
列表选择
select($list,$colQty,$msg,$mul);
参数 | 说明 | ||
---|---|---|---|
$list | array | 必须 | 可选清单 |
$colQty | int | 可选 | 列数,展示可选清单时,展示几列。默认:1 |
$msg | string | 可选 | 默认:请输入 |
$mul | bool | 可选 | 是否允许多选,默认:false |
移动光标
cursorMove(方位,移动量) 方位:l:left r:right u:up, d:down
光标定位 (移动光标到指定位置)
cursorPosition(x,y) y行x列
clear
clear();//清除屏幕
wait (等待/倒计时/模拟loading 等场景)
wait(int $s 秒,string $msg 消息);
progressBar (进度条绘制)
progressBar(int $total 总量,int $current 当前量, string $msg 文本信息)
All versions of cli with dependencies
PHP Build Version
Package Version
Requires
php Version
>=5.4
ext-mbstring Version *
ext-iconv Version *
ext-mbstring Version *
ext-iconv Version *
The package iry/cli contains the following files
Loading the files please wait ....