定制 rhdevelopment/arg-parser 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-23