Browse Source

fixed command line parser

develop
Robin Thoni 9 years ago
parent
commit
4a5214ddd6
1 changed files with 4 additions and 4 deletions
  1. 4
    4
      src/Interface/CommandLineParser.cpp

+ 4
- 4
src/Interface/CommandLineParser.cpp View File

31
     int option;
31
     int option;
32
     extern int optind;
32
     extern int optind;
33
     extern char* optarg;
33
     extern char* optarg;
34
-    bool valid = false;
34
+    bool valid = true;
35
     while ((option = getopt_long(_argc, _argv, shortOpts.c_str(), opts, 0)) != -1)
35
     while ((option = getopt_long(_argc, _argv, shortOpts.c_str(), opts, 0)) != -1)
36
     {
36
     {
37
+        bool optValid = false;
37
         for (unsigned i = 0; i < _options.size(); ++i)
38
         for (unsigned i = 0; i < _options.size(); ++i)
38
         {
39
         {
39
-            bool optValid = false;
40
             auto opt = _options[i];
40
             auto opt = _options[i];
41
             if (opt->getShortName() == option)
41
             if (opt->getShortName() == option)
42
             {
42
             {
45
                 if (opt->hasValue())
45
                 if (opt->hasValue())
46
                     opt->addValue(optarg);
46
                     opt->addValue(optarg);
47
             }
47
             }
48
-            if (!optValid)
49
-                valid = false;
50
         }
48
         }
49
+        if (!optValid)
50
+            valid = false;
51
     }
51
     }
52
     return optind == _argc && valid;
52
     return optind == _argc && valid;
53
 }
53
 }

Loading…
Cancel
Save