Skip to content

Commit bdc17b9

Browse files
committed
update readme
1 parent 39bce62 commit bdc17b9

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

README.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Generic PHP command line flags parse library
3838
composer require toolkit/pflag
3939
```
4040

41+
-----------
42+
4143
## Flags Usage
4244

4345
Flags - is an cli flags(options&argument) parser and manager.
@@ -62,6 +64,8 @@ $fs->setScriptFile($scriptFile);
6264
$fs->setSettings([
6365
'descNlOnOptLen' => 26
6466
]);
67+
68+
// ...
6569
```
6670

6771
### Define options
@@ -109,13 +113,16 @@ use Toolkit\PFlag\FlagType;
109113
// add arguments
110114
// - quick add
111115
$fs->addArg('strArg1', 'the is string arg and is required', 'string', true);
116+
112117
// - use string rule
113118
$fs->addArgByRule('intArg2', 'int;this is a int arg and with default value;no;89');
119+
114120
// - use Argument object
115121
$arg = Argument::new('arrArg');
116122
// OR $arg->setType(FlagType::ARRAY);
117123
$arg->setType(FlagType::STRINGS);
118124
$arg->setDesc("this is an array arg,\n allow multi value,\n must define at last");
125+
119126
$fs->addArgument($arg);
120127
```
121128

@@ -176,24 +183,12 @@ array(3) {
176183
}
177184
```
178185

186+
-----------
187+
179188
## SFlags Usage
180189

181190
SFlags - is an simple flags(options&argument) parser and manager.
182191

183-
> `SFlags` only support add option/argument by rule string or define array.
184-
185-
### Methods
186-
187-
Options:
188-
189-
- `setOptRules(array $rules)`
190-
- `addOptRule(string $name, string|array $rule)`
191-
192-
Arguments:
193-
194-
- `setArgRules(array $rules)`
195-
- `addArgRule(string $name, string|array $rule)`
196-
197192
### Examples
198193

199194
```php
@@ -300,6 +295,8 @@ array(2) {
300295
$ php example/sflags-demo.php --help
301296
```
302297

298+
-----------
299+
303300
## Get Value
304301

305302
**Options**
@@ -321,6 +318,8 @@ $arrArg = $fs->getArg(1); // array{"arr0", "arr1"}
321318
$arrArg = $fs->getArg('arrArg'); // array{"arr0", "arr1"}
322319
```
323320

321+
-----------
322+
324323
## Flag Rule
325324

326325
The options/arguments rules
@@ -374,6 +373,8 @@ public const DEFINE_ITEM = [
374373
];
375374
```
376375

376+
-----------
377+
377378
## Costom settings
378379

379380
### Settings for parse
@@ -466,6 +467,8 @@ $fs->setHelpRenderer(function (\Toolkit\PFlag\FlagsParser $fs) {
466467
});
467468
```
468469

470+
-----------
471+
469472
## Unit tests
470473

471474
```bash
@@ -478,6 +481,14 @@ test with coverage:
478481
phpdbg -qrr $(which phpunit) --coverage-text
479482
```
480483

484+
## Project use
485+
486+
Check out these projects, which use https://github.com/php-toolkit/pflag :
487+
488+
- [inhere/console](https://github.com/inhere/console) Full-featured php command line application library.
489+
- [kite](https://github.com/inhere/kite) Kite is a tool for help development.
490+
- More, please see [Packagist](https://packagist.org/packages/toolkit/pflag)
491+
481492
## License
482493

483494
[MIT](LICENSE)

0 commit comments

Comments
 (0)