PHP code example of iry / cli

1. Go to this page and download the library: Download iry/cli library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

iry / cli example snippets


use ir\cli\Cli;
$numeric = Cli::stdin('请输入');//等待并获取用户输入的数据
$numeric = Cli::stdin('请输入数字',function($v){return preg_match('/^[0-9]+$/',$v);},'trim');
$numeric = Cli::stdin('请输入数字',function($v){return preg_match('/^[0-9]+$/',$v);},'trim');

Cli::output('这是一个测试','success') 
Cli::output('这是一个测试','error')
Cli::output('这是一个测试',['purple','yellow'])
Cli::output([
    '这是',
    ['一个','error'],//使用error样式
    ['测试','yellow'],//使用info样式
    //string || ['$msg','$styleType']
]);

use ir\cli\Cli;
$confirm = Cli::confirm('你确认要删除吗?');

//效果如下
//你确认要删除吗?[y/n] _

use ir\cli\Cli;
$confirm = Cli::cursorMove('u',3); //光标上移三行
$confirm = Cli::cursorMove('l',4); //光标左移4个字符

use ir\cli\Cli;
$confirm = Cli::cursorPosition(3,5);//光标定位到5行第三个字符后面