Update README.md

This commit is contained in:
Pranav Srinivas Kumar 2019-03-31 17:51:08 -04:00 committed by GitHub
parent 48c6365ef5
commit 9120c7ef2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -77,6 +77,23 @@ Here's what's happening:
### Combining Positional and Optional Arguments
### List of Arguments
ArgumentParser objects usually associate a single command-line argument with a single action to be taken. The ```.nargs``` associates a different number of command-line arguments with a single action. When using ```nargs(N)```, N arguments from the command line will be gathered together into a list.
```cpp
argparse::ArgumentParser program("main");
program.add_argument("--input_files")
.help("The list of input files")
.nargs(3);
program.parse_args({"./main", "--input_files", "config.yml", "System.xml"});
auto files = program.get<std::vector<std::string>>("--input_files"); // {"config.yml", "System.xml"}
```
### Compound Arguments
Compound arguments are optional arguments that are combined and provided as a single argument. Example: ```ps -aux```
@ -175,20 +192,6 @@ std::string config = program.get("--config"); // "config.json"
int num_iterations = program.get<int>("-n"); // 36
```
### Vector of Arguments
```cpp
argparse::ArgumentParser program("main");
program.add_argument("--input_files")
.help("The list of input files")
.nargs(3);
program.parse_args({"./main", "--input_files", "config.yml", "System.xml"});
auto files = program.get<std::vector<std::string>>("--input_files"); // {"config.yml", "System.xml"}
```
### Positional Arguments with Compound Toggle Arguments
```cpp