2022-07-19 18:29:31 +00:00
|
|
|
**This requires enabling the [`derive` feature flag][crate::_features].**
|
2021-12-08 22:46:49 +00:00
|
|
|
|
2021-11-30 18:30:19 +00:00
|
|
|
You can use `--` to escape further arguments.
|
|
|
|
|
|
|
|
Let's see what this looks like in the help:
|
2022-01-05 16:54:33 +00:00
|
|
|
```console
|
2021-12-15 17:12:16 +00:00
|
|
|
$ escaped-positional-derive --help
|
2021-11-30 18:30:19 +00:00
|
|
|
A simple to use, efficient, and full-featured Command Line Argument Parser
|
|
|
|
|
2022-09-07 16:03:55 +00:00
|
|
|
Usage: escaped-positional-derive[EXE] [OPTIONS] [-- <SLOP>...]
|
2021-11-30 18:30:19 +00:00
|
|
|
|
2022-08-26 14:40:23 +00:00
|
|
|
Arguments:
|
2022-09-07 20:29:15 +00:00
|
|
|
[SLOP]...
|
2021-11-30 18:30:19 +00:00
|
|
|
|
2022-08-26 14:40:23 +00:00
|
|
|
Options:
|
2022-09-07 20:29:15 +00:00
|
|
|
-f
|
|
|
|
-p <PEAR>
|
|
|
|
-h, --help Print help information
|
|
|
|
-V, --version Print version information
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2021-11-30 18:30:19 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Here is a baseline without any arguments:
|
2022-01-05 16:54:33 +00:00
|
|
|
```console
|
2021-12-15 17:12:16 +00:00
|
|
|
$ escaped-positional-derive
|
2021-11-30 18:30:19 +00:00
|
|
|
-f used: false
|
|
|
|
-p's value: None
|
|
|
|
'slops' values: []
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2021-11-30 18:30:19 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Notice that we can't pass positional arguments before `--`:
|
2022-01-05 16:54:33 +00:00
|
|
|
```console
|
2021-12-15 17:12:16 +00:00
|
|
|
$ escaped-positional-derive foo bar
|
2021-11-30 18:30:19 +00:00
|
|
|
? failed
|
|
|
|
error: Found argument 'foo' which wasn't expected, or isn't valid in this context
|
|
|
|
|
2022-09-07 16:03:55 +00:00
|
|
|
Usage: escaped-positional-derive[EXE] [OPTIONS] [-- <SLOP>...]
|
2021-11-30 18:30:19 +00:00
|
|
|
|
2022-09-15 19:22:28 +00:00
|
|
|
For more information try '--help'
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2021-11-30 18:30:19 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
But you can after:
|
2022-01-05 16:54:33 +00:00
|
|
|
```console
|
2021-12-15 17:12:16 +00:00
|
|
|
$ escaped-positional-derive -f -p=bob -- sloppy slop slop
|
2021-11-30 18:30:19 +00:00
|
|
|
-f used: true
|
|
|
|
-p's value: Some("bob")
|
|
|
|
'slops' values: ["sloppy", "slop", "slop"]
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2021-11-30 18:30:19 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
As mentioned, the parser will directly pass everything through:
|
2022-01-05 16:54:33 +00:00
|
|
|
```console
|
2021-12-15 17:12:16 +00:00
|
|
|
$ escaped-positional-derive -- -f -p=bob sloppy slop slop
|
2021-11-30 18:30:19 +00:00
|
|
|
-f used: false
|
|
|
|
-p's value: None
|
|
|
|
'slops' values: ["-f", "-p=bob", "sloppy", "slop", "slop"]
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2021-11-30 18:30:19 +00:00
|
|
|
```
|