Added mechanism to understand passed Argument value.
[command.git] / include / command.h
index 0c18cdf11727c404f0743f100326d1de27c234db..ec0868180b94a2c7f29121a6e7b264b82f6c7c53 100644 (file)
@@ -27,7 +27,6 @@ namespace command {
             : parameters(params) {
 
             matchArguments(argc, argv);
-            invoke();
         }
 
         /**
@@ -42,16 +41,14 @@ namespace command {
         /**
          * Matches user passed arguments with available parameter handlers.
          */
-        void matchArguments(unsigned int , char **) {
-//             param->passUserValue();
-        }
-
-        /**
-         * Invokes passed parameter handlers
-         */
-        void invoke() {
-            for(Parameter *param : parameters) {
-                param->handle();
+        void matchArguments(unsigned int argc, char *argv[]) {
+            for (unsigned int i = 1; i < argc; i++) {
+                for(Parameter *param : parameters) {
+                    if (param->understand(argv[i])) {
+                        param->handle();
+                        break;
+                    }
+                }
             }
         }
     };