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

Loading…
Cancel
Save