add help to example1
This commit is contained in:
@@ -28,7 +28,8 @@ int main(int argc, char **argv) {
|
||||
// from string.
|
||||
|
||||
// An option invoked with `--repeat N`
|
||||
p.add_option(repeats, "--repeat")->help("how many times to repeat first argument");
|
||||
p.add_option(repeats, "--repeat")
|
||||
->help("how many times to repeat first argument");
|
||||
// A flag invoked with `--verbose` or `-v`
|
||||
p.add_flag(verbose, "--verbose", "-v");
|
||||
// a required positional argument (position 1)
|
||||
@@ -42,6 +43,12 @@ int main(int argc, char **argv) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// If help was requested, print it
|
||||
if (p.need_help()) {
|
||||
std::cerr << p.help();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Execute the program logic
|
||||
if (verbose) {
|
||||
std::cerr << "about to print '" << toPrint << "' " << repeats << " times";
|
||||
|
@@ -15,7 +15,8 @@ int main(int argc, char **argv) {
|
||||
// from string.
|
||||
|
||||
// An option invoked with `--repeat N`
|
||||
p.add_option(repeats, "--repeat")->help("how many times to repeat first argument");
|
||||
p.add_option(repeats, "--repeat")
|
||||
->help("how many times to repeat first argument");
|
||||
// A flag invoked with `--verbose` or `-v`
|
||||
p.add_flag(verbose, "--verbose", "-v");
|
||||
// a required positional argument (position 1)
|
||||
@@ -29,6 +30,12 @@ int main(int argc, char **argv) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// If help was requested, print it
|
||||
if (p.need_help()) {
|
||||
std::cerr << p.help();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Execute the program logic
|
||||
if (verbose) {
|
||||
std::cerr << "about to print '" << toPrint << "' " << repeats << " times";
|
||||
|
Reference in New Issue
Block a user