describe --
This commit is contained in:
19
README.md
19
README.md
@@ -68,6 +68,7 @@ int main(int argc, char **argv) {
|
|||||||
Options may be `int`, `size_t`, `float`, `double`, or `std::string` and currently support long strings.
|
Options may be `int`, `size_t`, `float`, `double`, or `std::string` and currently support long strings.
|
||||||
They are invoked like `--long-opt value` (not `--long-opt=value`).
|
They are invoked like `--long-opt value` (not `--long-opt=value`).
|
||||||
|
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
Parser p;
|
Parser p;
|
||||||
p.add_option(var1, "--long-opt")
|
p.add_option(var1, "--long-opt")
|
||||||
@@ -101,6 +102,24 @@ if (something->found()) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Anything after `--` is considered a positional argument, unless -- follows an option.
|
||||||
|
Here, the first `--` is the value for `--option` and will be in `s1`.
|
||||||
|
The second `--` marks the beginning of positional arguments. and the string `aa` will be in `s2`.
|
||||||
|
|
||||||
|
```c++
|
||||||
|
Parser p;
|
||||||
|
std::string s1, s2;
|
||||||
|
p.add_option(s1, "--option");
|
||||||
|
p.add_positional(s2);
|
||||||
|
std::cerr << s1;
|
||||||
|
std::cerr << s2;
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ ./myexe --option -- -- aa
|
||||||
|
--aa
|
||||||
|
```
|
||||||
|
|
||||||
## Parsing
|
## Parsing
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
|
Reference in New Issue
Block a user