mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 07:04:39 +00:00
Update README.md
This commit is contained in:
parent
d0acbfdfb6
commit
87c42cd3ea
13
README.md
13
README.md
@ -88,7 +88,7 @@ program.add_argument("--verbose")
|
|||||||
.default_value(false)
|
.default_value(false)
|
||||||
.implicit_value(true);
|
.implicit_value(true);
|
||||||
|
|
||||||
program.parse_args({ "./main", "4", "--verbose" });
|
program.parse_args(argc, argv);
|
||||||
|
|
||||||
int input = program.get<int>("square");
|
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
|
### 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.
|
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user