Add simple example and improve README file.
[command.git] / docs / examples / basic / example.cpp
1 #include <iostream>
2 #include <command/command.h>
3 #include <command/option.h>
4
5 using namespace command;
6
7 /**
8  * Just a simple example allowing to display help information if user will set
9  * command line option: -h, e.g.:
10  *
11  *  ./a.out -h
12  *
13  */
14 int main(int argc, char *argv[]) {
15     try {
16         Command command(argc, argv, {
17             new Option<void>("-h", "Help", [](void) {
18                 std::cout << "Help information\n";
19             })
20         });
21     }
22     catch(const std::exception & e) {
23         return 1;
24     }
25
26     return 0;
27 }