diff --git a/README.md b/README.md index b0b7354..56ab896 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ argparse::ArgumentParser program("main"); program.add_argument("--input_files") .help("The list of input files") - .nargs(3); + .nargs(2); program.parse_args({"./main", "--input_files", "config.yml", "System.xml"}); @@ -128,32 +128,10 @@ Here's what's happening: - ```-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```. - -Notice how argparse is able to quietly and peacefully return an std::vector when asked for it. - -```cpp -auto c_vector = program.get>("-c"); -auto c_list = program.get>("-c"); -``` - -Both of these above statements will work. Argparse has specializations implemented for both ```std::vector``` and ```std::list```. +* Notice how argparse is able to quietly and peacefully return an std::vector when asked for it. ## Examples -### Positional Arguments - -```cpp -argparse::ArgumentParser program("main"); - -program.add_argument("input"); -program.add_argument("output"); - -program.parse_args({"./main", "rocket.msh", "thrust_profile.csv"}); - -std::string input = program.get("input"); // "rocket.msh" -std::string output = program.get("output"); // "thrust_profile.csv" -``` - ### Construct a JSON object from a filename argument ```cpp @@ -173,25 +151,6 @@ program.parse_args({"./test", "config.json"}); nlohmann::json config = program.get("config"); ``` -### Optional Arguments - -```cpp -argparse::ArgumentParser program("main"); - -program.add_argument("--config") - .help("configuration file") - .default_value(std::string("config.json")); - -program.add_argument("-n", "--num_iterations") - .help("The list of input files") - .action([](const std::string& value) { return std::stoi(value); }); - -program.parse_args({"./main", "-n", "36"}); - -std::string config = program.get("--config"); // "config.json" -int num_iterations = program.get("-n"); // 36 -``` - ### Positional Arguments with Compound Toggle Arguments ```cpp