mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 15:14:39 +00:00
Update README.md
This commit is contained in:
parent
d5c6f7c8ef
commit
b3c83177e4
12
README.md
12
README.md
@ -81,9 +81,6 @@ Here's what's happening:
|
|||||||
|
|
||||||
Compound arguments are optional arguments that are combined and provided as a single argument. Example: ```ps -aux```
|
Compound arguments are optional arguments that are combined and provided as a single argument. Example: ```ps -aux```
|
||||||
|
|
||||||
* Here are three optional arguments ```-a```, ```-b``` and ```-c```.
|
|
||||||
* ```-c``` requires 2 floating point numbers from the command-line. ```-a``` and ```-b``` are toggle arguments.
|
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
argparse::ArgumentParser program("test");
|
argparse::ArgumentParser program("test");
|
||||||
|
|
||||||
@ -106,6 +103,15 @@ auto b = program.get<bool>("-b"); // true
|
|||||||
auto c = program.get<std::vector<float>>("-c"); // {3.14f, 2.718f}
|
auto c = program.get<std::vector<float>>("-c"); // {3.14f, 2.718f}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Here's what's happening:
|
||||||
|
* We have three optional arguments ```-a```, ```-b``` and ```-c```.
|
||||||
|
* ```-a``` and ```-b``` are toggle arguments.
|
||||||
|
* ```-c``` requires 2 floating point numbers from the command-line. You can specify how many inputs to expect using ```nargs```.
|
||||||
|
* argparse can handle compound arguments ```-abc``` and ```-bac```. This only works with short single-character argument names.
|
||||||
|
- ```-a``` and ```-b``` become true.
|
||||||
|
- argv is further parsed to identify the inputs mapped to ```-c```.
|
||||||
|
* Using ```-cab``` will throw an error since argparse expects two inputs for the argument ```-c```.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### Positional Arguments
|
### Positional Arguments
|
||||||
|
Loading…
Reference in New Issue
Block a user