Browse Source

cmCommandLineArgument now supports OneOrMore argument type

Robert Maynard 4 years ago
parent
commit
5ab0b54482
1 changed files with 18 additions and 0 deletions
  1. 18 0
      Source/cmCommandLineArgument.h

+ 18 - 0
Source/cmCommandLineArgument.h

@@ -14,6 +14,7 @@ struct cmCommandLineArgument
     One,
     One,
     Two,
     Two,
     ZeroOrOne,
     ZeroOrOne,
+    OneOrMore
   };
   };
 
 
   std::string InvalidSyntaxMessage;
   std::string InvalidSyntaxMessage;
@@ -129,6 +130,23 @@ struct cmCommandLineArgument
             : ParseMode::Invalid;
             : ParseMode::Invalid;
         }
         }
       }
       }
+    } else if (this->Type == Values::OneOrMore) {
+      if (input.size() == this->Name.size()) {
+        auto nextValueIndex = index + 1;
+        if (nextValueIndex >= allArgs.size() || allArgs[index + 1][0] == '-') {
+          parseState = ParseMode::ValueError;
+        } else {
+          std::string buffer = allArgs[nextValueIndex++];
+          while (nextValueIndex < allArgs.size() &&
+                 allArgs[nextValueIndex][0] != '-') {
+            buffer = cmStrCat(buffer, ";", allArgs[nextValueIndex++]);
+          }
+          parseState =
+            this->StoreCall(buffer, std::forward<CallState>(state)...)
+            ? ParseMode::Valid
+            : ParseMode::Invalid;
+        }
+      }
     }
     }
 
 
     if (parseState == ParseMode::SyntaxError) {
     if (parseState == ParseMode::SyntaxError) {