imgurbot12/slap
最新稳定版本:0.1.0
Composer 安装命令:
composer require imgurbot12/slap
包简介
A PHP CLI Library Inspired by Rust's CLAP
README 文档
README
A PHP CLI Library Inspired by Rust's CLAP
Installation
$ composer require imgurbot12/slap
Usage
Slap supports a standard CLI builder mode which returns an untyped array as a result:
use Imgurbot12\Slap\Arg; use Imgurbot12\Slap\Command; use Imgurbot12\Slap\Flag; $app = Command::new('myapp') ->args(Arg::new('foo')->about('foo description')) ->flags(Flag::new('test')->short('t')->default('hello')) ->subcommands( Command::new('bar')->args(Arg::new('baz')->default('world')); $result = $app->parse(); print_r($result);
It also includes a derivation mode similar to clap:
use Imgurbot12\Slap\Derive\Command; use Imgurbot12\Slap\Derive\Flag; use Imgurbot12\Slap\Derive\Parser; use Imgurbot12\Slap\Derive\SubCommands; #[Command(name: 'bar')] class Bar { public string $baz = 'world'; } class Commands extends SubCommands { public Bar $bar; } #[Command(name: 'myapp')] class MyApp extends Parser { /** foo description */ public string $foo; #[Flag(short: 't')] public string $test = 'hello'; public Commands $command; } $result = MyApp::parse(); print_r($result);
统计信息
- 总下载量: 357
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-22