• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1**This requires enabling the [`derive` feature flag][crate::_features].**
2
3You can use `--` to escape further arguments.
4
5Let's see what this looks like in the help:
6```console
7$ escaped-positional-derive --help
8A simple to use, efficient, and full-featured Command Line Argument Parser
9
10Usage: escaped-positional-derive[EXE] [OPTIONS] [-- <SLOP>...]
11
12Arguments:
13  [SLOP]...
14
15Options:
16  -f
17  -p <PEAR>
18  -h, --help     Print help
19  -V, --version  Print version
20
21```
22
23Here 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
32Notice that we can't pass positional arguments before `--`:
33```console
34$ escaped-positional-derive foo bar
35? failed
36error: unexpected argument 'foo' found
37
38Usage: escaped-positional-derive[EXE] [OPTIONS] [-- <SLOP>...]
39
40For more information, try '--help'.
41
42```
43
44But 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
53As 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```
61