panodream/php-simpcli

简单的PHP命令行参数解析器

dev-master 2018-11-03 06:39 UTC

This package is auto-updated.

Last update: 2024-09-29 05:02:13 UTC


README

简单的PHP命令行参数解析器

安装

composer require pangodream/php-simpcli

使用

require_once __DIR__.'/../vendor/autoload.php';

use PhpSimpcli\CliParser;

$sp = new CliParser();

var_dump($sp->get('myOption'));

从命令行控制台

php test.php -otherOption 

["found"] => bool(false)
["value"] => NULL
["type"]  => NULL

php test.php -myOption 

["found"] => bool(true)
["value"] => NULL
["type"]  => "missing"

php test.php -myOption Hello

["found"] => bool(true)
["value"] => "Hello"
["type"]  => "single"

php test.php -myOption Hello World

["found"] => bool(true)
["value"] => array([0] => "Hello, [1] => "World")
["type"]  => multi

php test.php -myOption Hello "Wonderful World"

["found"] => bool(true)
["value"] => array([0] => "Hello, [1] => "Wonderful World")
["type"]  => multi