diff --git a/README.md b/README.md index 22f479a..9311d43 100644 --- a/README.md +++ b/README.md @@ -28,11 +28,16 @@ int main(int argc, char **argv) { std::string maybePrint; int repeats = 1; - // Inform the parser of the program data. - // It will do type-specific conversion + // Inform the parser of the program data. It will do type-specific conversion + // from string. + + // An option invoked with `--repeat N` p.add_option(repeats, "--repeat"); + // A flag invoked with `--verbose` or `-v` p.add_flag(verbose, "--verbose", "-v"); + // a required positional argument (position 1) p.add_positional(toPrint)->required(); + // an optional positional argument (position 2) auto psnl = p.add_positional(maybePrint); // If there was an error during parsing, report it. @@ -45,7 +50,7 @@ int main(int argc, char **argv) { if (verbose) { std::cerr << "about to print '" << toPrint << "' " << repeats << " times"; if (psnl->found()) { - std::cerr << ", then '" << maybePrint << "'"; + std::cerr << ", then '" << maybePrint << "'"; } std::cerr << std::endl; } diff --git a/examples/example1.cpp b/examples/example1.cpp index 2d2fc0d..b4d3001 100644 --- a/examples/example1.cpp +++ b/examples/example1.cpp @@ -11,11 +11,16 @@ int main(int argc, char **argv) { std::string maybePrint; int repeats = 1; - // Inform the parser of the program data. - // It will do type-specific conversion + // Inform the parser of the program data. It will do type-specific conversion + // from string. + + // An option invoked with `--repeat N` p.add_option(repeats, "--repeat"); + // A flag invoked with `--verbose` or `-v` p.add_flag(verbose, "--verbose", "-v"); + // a required positional argument (position 1) p.add_positional(toPrint)->required(); + // an optional positional argument (position 2) auto psnl = p.add_positional(maybePrint); // If there was an error during parsing, report it.