cmCommandLineArgument now supports OneOrMore argument type

This commit is contained in:
Robert Maynard
2020-12-30 09:01:11 -05:00
committed by Brad King
parent b34db1db69
commit 5ab0b54482

View File

@@ -14,6 +14,7 @@ struct cmCommandLineArgument
One,
Two,
ZeroOrOne,
OneOrMore
};
std::string InvalidSyntaxMessage;
@@ -129,6 +130,23 @@ struct cmCommandLineArgument
: 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) {