Skip to content

Commit 0e3929d

Browse files
committed
pre release v1.0.0
1 parent 5c5cf14 commit 0e3929d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,34 @@ This class is not workable when [register_argc_argv](http://php.net/manual/en/in
1616

1717
## Usage
1818

19+
### Example
20+
21+
run
22+
```
23+
> example.php --name=Alexander --age=32 --sex=m
24+
or
25+
> example.php -n Alexander -a 32 -s m
26+
```
27+
28+
example.php
29+
```php
30+
$config = [
31+
'name' => 'n',
32+
'age' => 'a',
33+
'sex' => 's'
34+
];
35+
$CliArgs = new CliArgs($config);
36+
37+
echo $CliArgs->getArg('name'); // Alexander
38+
echo $CliArgs->getArg('n'); // Alexander
39+
40+
echo $CliArgs->getArg('age'); // 42
41+
echo $CliArgs->getArg('a'); // 42
42+
43+
echo $CliArgs->getArg('sex'); // m
44+
echo $CliArgs->getArg('s'); // m
45+
```
46+
1947
### Config
2048

2149
Note: all params from cli that you want to use should be specified in config, otherwise they will be ignored.

0 commit comments

Comments
 (0)