|
6 | 6 |
|
7 | 7 | - [benchmark](#benchmark)
|
8 | 8 | - [compose](#compose)
|
| 9 | +- [parse_args](#parse_args) |
9 | 10 | - [parse_params](#parse_params)
|
10 | 11 | - [repeat](#repeat)
|
11 | 12 | - [sedi](#sedi)
|
|
32 | 33 | - Test Cases: [tests/modules/compose.bats](../../tests/modules/compose.bats)
|
33 | 34 | - Source Code: [src/modules/compose.bash](../../src/modules/compose.bash)
|
34 | 35 |
|
| 36 | +### parse_args |
| 37 | + |
| 38 | +- Usage: `l.parse_args <definition> "$@"` |
| 39 | +- Description: |
| 40 | + - the `definition` is an associative array, which likes {[opts]=opts_name [args]=args_name ['-f,--flag']='bool'}. |
| 41 | + - The `[opts]` and `[args]` are required for `<definition>`. |
| 42 | + - It parses all parameters "$@". Put arguments to the `args_name` and options to `opts_name`. |
| 43 | + - The `opts_name` must be an associative array or `_`. If set `_`, the options will be ignored. |
| 44 | + - The `args_name` must be an array or `_`. If set `_`, the arguments will be ignored. |
| 45 | + - The option has tree type: |
| 46 | + - "bool": For example, `-f`, `--flag` means `${f}` and `${flag}` equal to `"true"` and `--no-f` and `--no-flag` equal to `"false"`. |
| 47 | + - "count": the value of option defaults to 0. And increasing count by times. For example: `-v` `-vv` `-vvv`. |
| 48 | + - "kv": key/value. It means the option must has an argument. If user not pass argument to "kv" option. It will print error and stop. |
| 49 | + - See test cases for details. |
| 50 | +- Dependent: [`each`](./array.md#each) [`match_list`](./string.md#match_list) [`var_attrs`](./variable.md#var_attrs) |
| 51 | +- Since: 0.7.0 |
| 52 | +- Bash: 4.0+ |
| 53 | +- **Notice**: **Only with bash 4.3, there may be something wrong if opts and args are not array.** |
| 54 | +- Test Cases: [tests/modules/parse_args.bats](../../tests/modules/parse_args.bats) |
| 55 | +- Source Code: [src/modules/parse_args.bash](../../src/modules/parse_args.bash) |
| 56 | +- Example: [example/modules/parse_args](../../example/modules/parse_args) |
| 57 | + |
35 | 58 | ### parse_params
|
36 | 59 |
|
37 | 60 | - Usage:
|
|
44 | 67 | - `args_name` must be an array or `_`. If `_`, no arguments will be parsed.
|
45 | 68 | - See test cases for details.
|
46 | 69 | - Dependent: [`start_with`](./condition.md#start_with) [`match`](./string.md#match) [`match_list`](./string.md#match_list)
|
| 70 | +- Deprecated: true |
47 | 71 | - Since: 0.4.0
|
48 | 72 | - Bash: 4.0+
|
49 | 73 | - Test Cases: [tests/modules/parse_params.bats](../../tests/modules/parse_params.bats)
|
|
0 commit comments