Update example.
[command.git] / src / main.cpp
index 017434559a71c9eca8c6e30f223d481c5d826f91..06fbf1e14bd7befddfa64ccff38b62e5402edc19 100644 (file)
@@ -3,22 +3,37 @@
 
 #include "option.h"
 #include "argument.h"
+#include "required.h"
+#include "multiValue.h"
 #include "command.h"
 
-void some_function(bool a) {
-    std::cout << "Some function " << a << std::endl;
+using namespace command;
+
+void argument_function(bool a) {
+    std::cout << "Argument: " << a << std::endl;
+}
+
+void option_function(std::string a) {
+    std::cout << "Help function " << a << std::endl;
 }
 
-void help_function(std::string a) {
-    std::cout << "Some function " << a << std::endl;
+void void_function(void) {
+    std::cout << "Void function " << std::endl;
 }
 
 int main(int argc, char *argv[]) {
-    command::Command command(argc, argv, {
-//         new command::Argument<std::string>("File path", [](std::string value)->void { std::cout << "Hello from lambda " << value << std::endl; }),
-        new command::Argument<bool>("File path", some_function),
-        new command::Option<std::string>("h", "Help", help_function)
-    });
+    try {
+        Command command(argc, argv, {
+//             new Argument<std::string>("File path", [](std::string value)->void { std::cout << "Hello from lambda " << value << std::endl; }),
+            new Required(new MultiValue("-", new Argument<bool>("Input values", argument_function))),
+            new MultiValue(",", new Option<std::string>("f", "Optional file", option_function)),
+            new Option<void>("h", "Help", void_function)
+        });
+
+    }
+    catch(const std::exception & e) {
+        std::cout << e.what() << std::endl;
+    }
 
     return 0;
 }
\ No newline at end of file