8
8
9
9
通用 PHP 命令行标志(选项和参数)解析库
10
10
11
+ > Github: [ php-toolkit/pflag] ( https://github.com/php-toolkit/pflag )
12
+
11
13
## [ EN README] ( README.md )
12
14
13
15
## 功能说明
@@ -66,7 +68,7 @@ $scriptFile = array_shift($flags);
66
68
67
69
$fs = Flags::new();
68
70
69
- // (可选的)可以添加一些自定义
71
+ // (可选的)可以添加一些自定义设置
70
72
$fs->setScriptFile($scriptFile);
71
73
/** @see Flags::$settings */
72
74
$fs->setSettings([
@@ -360,15 +362,17 @@ $arrArg = $fs->getArg('arrArg'); // array{"arr0", "arr1"}
360
362
- 支持的类型常量请看 ` FlagType::* `
361
363
362
364
``` php
365
+ use Toolkit\PFlag\FlagType;
366
+
363
367
$rules = [
364
- // v: only value, as name and use default type FlagType::STRING
365
- // k-v: key is name, value can be string|array
368
+ // v: 只有值,作为名称并使用默认类型 FlagType::STRING
369
+ // k-v: 键是名称,值可以是字符串|数组
366
370
'long,s',
367
371
// name => rule
368
- 'long,a,b' => 'int', // long is option name, a and b is shorts.
369
- 'f' => 'bool' ,
370
- 'long ' => FlagType::STRING ,
371
- 'tags' => 'array', // can also: ints, strings
372
+ 'long,a,b' => 'int;an int option ', // long is option name, a and b is shorts.
373
+ 'f' => FlagType::BOOL ,
374
+ 'str1 ' => ['type' => 'int', 'desc' => 'an string option'] ,
375
+ 'tags' => 'array; an array option ', // can also: ints, strings
372
376
'name' => 'type;the description message;required;default', // with desc, default, required
373
377
]
374
378
```
@@ -384,9 +388,9 @@ $rules = [
384
388
- 参数没有别名或者短名称
385
389
- 数组参数只允许定义在最后
386
390
387
- ** Definition item **
391
+ ** 数组定义项 **
388
392
389
- The const ` Flags::DEFINE_ITEM ` :
393
+ 常量 ` Flags::DEFINE_ITEM ` :
390
394
391
395
``` php
392
396
public const DEFINE_ITEM = [
0 commit comments