mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-29 18:51:05 -05:00
cmCommandLineArgument supports ZeroOrOne arguments
This allows us to parse command line arguments such as `-j` || `-j2`
This commit is contained in:
committed by
Brad King
parent
0fb78576b0
commit
b34db1db69
@@ -13,6 +13,7 @@ struct cmCommandLineArgument
|
||||
Zero,
|
||||
One,
|
||||
Two,
|
||||
ZeroOrOne,
|
||||
};
|
||||
|
||||
std::string InvalidSyntaxMessage;
|
||||
@@ -72,11 +73,18 @@ struct cmCommandLineArgument
|
||||
parseState = ParseMode::SyntaxError;
|
||||
}
|
||||
|
||||
} else if (this->Type == Values::One) {
|
||||
} else if (this->Type == Values::One || this->Type == Values::ZeroOrOne) {
|
||||
if (input.size() == this->Name.size()) {
|
||||
++index;
|
||||
if (index >= allArgs.size() || allArgs[index][0] == '-') {
|
||||
parseState = ParseMode::ValueError;
|
||||
if (this->Type == Values::ZeroOrOne) {
|
||||
parseState =
|
||||
this->StoreCall(std::string{}, std::forward<CallState>(state)...)
|
||||
? ParseMode::Valid
|
||||
: ParseMode::Invalid;
|
||||
} else {
|
||||
parseState = ParseMode::ValueError;
|
||||
}
|
||||
} else {
|
||||
parseState =
|
||||
this->StoreCall(allArgs[index], std::forward<CallState>(state)...)
|
||||
|
||||
Reference in New Issue
Block a user