Skip to content

Commit a3351ca

Browse files
committed
Update documentation of ex1
1 parent 8e08317 commit a3351ca

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/examples/ex1/ex1.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,40 @@
2929

3030
using juzzlin::Argengine;
3131

32+
//
33+
// Ex1: Demonstrate basic usage.
34+
//
35+
3236
int main(int argc, char ** argv)
3337
{
38+
// Instantiate Argengine and give it the raw argument data.
3439
Argengine ae(argc, argv);
40+
41+
// Add option "-a" that, when set, prints all arguments given to the binary.
3542
ae.addOption(
3643
{ "-a", "--arguments" }, [&] {
3744
for (int i = 0; i < argc; i++) {
3845
std::cout << argv[i] << std::endl;
3946
}
4047
},
41-
false, "Print arguments.");
48+
false, "Print arguments."); // Set the option non-required and set documentation string.
49+
50+
// Add option "-p" that prints the length of the given string e.g. "-p FOO".
4251
ae.addOption(
4352
{ "-p" }, [](std::string value) {
4453
std::cout << value.size() << std::endl;
4554
},
46-
true, "Print length of given text. This option is required.", "TEXT");
55+
true, "Print length of given text. This option is required.", "TEXT"); // Set the option required and set documentation string and variable name shown in the documentation.
4756

57+
// Parse the arguments and store possible error to variable error.
4858
Argengine::Error error;
4959
ae.parse(error);
5060

61+
// Check error and print the possible error message.
5162
if (error.code != Argengine::Error::Code::Ok) {
5263
std::cerr << error.message << std::endl
5364
<< std::endl;
54-
ae.printHelp();
65+
ae.printHelp(); // Print the auto-generated help.
5566
return EXIT_FAILURE;
5667
}
5768

0 commit comments

Comments
 (0)