Update README.md

This commit is contained in:
Pranav Srinivas Kumar 2019-04-01 21:53:04 -04:00 committed by GitHub
parent 5bf9b958f6
commit 11729b4dfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,12 +27,20 @@ Argparse supports a variety of argument types including positional, optional, an
Here's an example of a ***positional argument***: Here's an example of a ***positional argument***:
```cpp ```cpp
#include <argparse.hpp>
int main(int argc, char *argv[]) {
argparse::ArgumentParser program("program name");
program.add_argument("square") program.add_argument("square")
.help("display the square of a given integer") .help("display the square of a given integer")
.action([](const std::string& value) { return pow(std::stoi(value), 2); }); .action([](const std::string& value) { return pow(std::stoi(value), 2); });
program.parse_args(argc, argv); program.parse_args(argc, argv);
std::cout << program.get<double>("square") << std::endl; std::cout << program.get<double>("square") << std::endl;
return 0;
}
``` ```
And running the code: And running the code: