5ad96a22520a2e9f5c1547e8e184d2f3f3a3e674
[command.git] / src / main.cpp
1 #include <iostream>
2 #include <string>
3
4 #include "option.h"
5 #include "argument.h"
6 #include "required.h"
7 #include "multiValue.h"
8 #include "grouped.h"
9 #include "command.h"
10
11 using namespace command;
12
13 void argument_function(bool a) {
14     std::cout << "Argument: " << a << std::endl;
15 }
16
17 void option_function(std::string a) {
18     std::cout << "Help function " << a << std::endl;
19 }
20
21 void void_function(void) {
22     std::cout << "Void function " << std::endl;
23 }
24
25 int main(int argc, char *argv[]) {
26     try {
27         Command command(argc, argv, {
28             new Grouped({
29                 new Required(new MultiValue("-", new Argument<bool>("Input values", argument_function))),
30                 new MultiValue(",", new Option<std::string>("f", "Optional file", option_function))
31             }),
32             new Option<void>("h", "Help", void_function)
33         });
34     }
35     catch(const std::exception & e) {
36         std::cout << e.what() << std::endl;
37     }
38
39     return 0;
40 }