Update README.md

This commit is contained in:
Pranav Srinivas Kumar 2019-03-31 18:08:37 -04:00 committed by GitHub
parent d0acbfdfb6
commit 87c42cd3ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,7 +88,7 @@ program.add_argument("--verbose")
.default_value(false)
.implicit_value(true);
program.parse_args({ "./main", "4", "--verbose" });
program.parse_args(argc, argv);
int input = program.get<int>("square");
@ -100,6 +100,17 @@ else {
}
```
```bash
$ ./main 4
16
$ ./main 4 --verbose
The square of 4 is 16
$ ./main --verbose 4
The square of 4 is 16
```
### 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.