Skip to content

Commit 76689ad

Browse files
committed
style: update readme
1 parent c6cd2a0 commit 76689ad

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
Generic PHP command line flags parse library
1010

11+
> Github: [php-toolkit/pflag](https://github.com/php-toolkit/pflag)
12+
1113
## [中文说明](README.zh-CN.md)
1214

1315
## Features
@@ -344,14 +346,16 @@ The options/arguments rules. Use rule can quick define an option or argument.
344346
- supportted type see `FlagType::*`
345347

346348
```php
349+
use Toolkit\PFlag\FlagType;
350+
347351
$rules = [
348352
// v: only value, as name and use default type FlagType::STRING
349353
// k-v: key is name, value can be string|array
350354
'long,s',
351355
// name => rule
352356
'long,a,b' => 'int', // long is option name, a and b is shorts.
353-
'f' => 'bool',
354-
'long' => FlagType::STRING,
357+
'f' => FlagType::BOOL,
358+
'str1' => ['type' => 'int', 'desc' => 'an string option'],
355359
'tags' => 'array', // can also: ints, strings
356360
'name' => 'type;the description message;required;default', // with desc, default, required
357361
]

README.zh-CN.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
通用 PHP 命令行标志(选项和参数)解析库
1010

11+
> Github: [php-toolkit/pflag](https://github.com/php-toolkit/pflag)
12+
1113
## [EN README](README.md)
1214

1315
## 功能说明
@@ -66,7 +68,7 @@ $scriptFile = array_shift($flags);
6668

6769
$fs = Flags::new();
6870

69-
// (可选的)可以添加一些自定义
71+
// (可选的)可以添加一些自定义设置
7072
$fs->setScriptFile($scriptFile);
7173
/** @see Flags::$settings */
7274
$fs->setSettings([
@@ -360,15 +362,17 @@ $arrArg = $fs->getArg('arrArg'); // array{"arr0", "arr1"}
360362
- 支持的类型常量请看 `FlagType::*`
361363

362364
```php
365+
use Toolkit\PFlag\FlagType;
366+
363367
$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: 键是名称,值可以是字符串|数组
366370
'long,s',
367371
// 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
372376
'name' => 'type;the description message;required;default', // with desc, default, required
373377
]
374378
```
@@ -384,9 +388,9 @@ $rules = [
384388
- 参数没有别名或者短名称
385389
- 数组参数只允许定义在最后
386390

387-
**Definition item**
391+
**数组定义项**
388392

389-
The const `Flags::DEFINE_ITEM`:
393+
常量 `Flags::DEFINE_ITEM`:
390394

391395
```php
392396
public const DEFINE_ITEM = [

0 commit comments

Comments
 (0)