| 1 |
**This requires enabling the [`derive` feature flag][crate::_features].** |
| 2 |
|
| 3 |
You can use `--` to escape further arguments. |
| 4 |
|
| 5 |
Let's see what this looks like in the help: |
| 6 |
```console |
| 7 |
$ escaped-positional-derive --help |
| 8 |
A simple to use, efficient, and full-featured Command Line Argument Parser |
| 9 |
|
| 10 |
Usage: escaped-positional-derive[EXE] [OPTIONS] [-- <SLOP>...] |
| 11 |
|
| 12 |
Arguments: |
| 13 |
[SLOP]... |
| 14 |
|
| 15 |
Options: |
| 16 |
-f |
| 17 |
-p <PEAR> |
| 18 |
-h, --help Print help |
| 19 |
-V, --version Print version |
| 20 |
|
| 21 |
``` |
| 22 |
|
| 23 |
Here is a baseline without any arguments: |
| 24 |
```console |
| 25 |
$ escaped-positional-derive |
| 26 |
-f used: false |
| 27 |
-p's value: None |
| 28 |
'slops' values: [] |
| 29 |
|
| 30 |
``` |
| 31 |
|
| 32 |
Notice that we can't pass positional arguments before `--`: |
| 33 |
```console |
| 34 |
$ escaped-positional-derive foo bar |
| 35 |
? failed |
| 36 |
error: unexpected argument 'foo' found |
| 37 |
|
| 38 |
Usage: escaped-positional-derive[EXE] [OPTIONS] [-- <SLOP>...] |
| 39 |
|
| 40 |
For more information, try '--help'. |
| 41 |
|
| 42 |
``` |
| 43 |
|
| 44 |
But you can after: |
| 45 |
```console |
| 46 |
$ escaped-positional-derive -f -p=bob -- sloppy slop slop |
| 47 |
-f used: true |
| 48 |
-p's value: Some("bob") |
| 49 |
'slops' values: ["sloppy", "slop", "slop"] |
| 50 |
|
| 51 |
``` |
| 52 |
|
| 53 |
As mentioned, the parser will directly pass everything through: |
| 54 |
```console |
| 55 |
$ escaped-positional-derive -- -f -p=bob sloppy slop slop |
| 56 |
-f used: false |
| 57 |
-p's value: None |
| 58 |
'slops' values: ["-f", "-p=bob", "sloppy", "slop", "slop"] |
| 59 |
|
| 60 |
``` |