improve example

This commit is contained in:
Carl Pearson
2020-03-24 13:00:06 -05:00
parent ee63e05ac9
commit 260cb18ee0
2 changed files with 15 additions and 5 deletions

View File

@@ -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.

View File

@@ -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.