rhdevelopment/arg-parser
最新稳定版本:v0.1.0
Composer 安装命令:
composer require rhdevelopment/arg-parser
包简介
Small, easy-to-use CLI argument parsing helpers for PHP scripts and cron tools.
README 文档
README
Small, easy-to-use CLI argument parsing helpers for PHP scripts and cron tools.
Usage sketch:
use RHDevelopment\ArgParser\ArgParser; ArgParser::option('name')->required()->asInt(); ArgParser::option('verbose'); $values = ArgParser::parse(); // $values is an associative array of parsed options
Interactive prompting helper
This package provides a small prompt() helper for interactive scripts. It reads from STDIN and returns the trimmed input. If you provide a default value and the user submits an empty line the default will be returned.
Example (see bin/example.php):
use RHDevelopment\ArgParser\ArgParser; ArgParser::option('name')->asString(); ArgParser::option('count')->asInt()->default(1); ArgParser::option('verbose'); $values = ArgParser::parse(); if (empty($values['name'])) { $values['name'] = ArgParser::prompt('Enter your name', 'guest'); }
Run the provided example script (make it executable first):
chmod +x bin/example.php ./bin/example.php --verbose --count=3
Run tests:
composer install
composer test
License: MIT (see LICENSE)
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-23