Browse Source

Util: Support for optional arguments in ArgParser

master
Riyyi 3 years ago
parent
commit
b6bfcbdc33
  1. 17
      src/util/argparser.cpp

17
src/util/argparser.cpp

@ -191,21 +191,30 @@ bool ArgParser::parseLongOption(std::string_view option, std::string_view next)
bool ArgParser::parseArgument(std::string_view argument)
{
// No handler for argument
bool result = true;
for (;;) {
// Run out of argument handlers
if (m_argumentIndex >= m_arguments.size()) {
return false;
}
Argument& currentArgument = m_arguments.at(m_argumentIndex);
bool result = currentArgument.acceptValue(argument.data());
result = currentArgument.acceptValue(argument.data());
if (result) {
currentArgument.addedValues++;
}
if (currentArgument.addedValues >= currentArgument.maxValues) {
m_argumentIndex++;
}
}
else if (currentArgument.minValues == 0) {
m_argumentIndex++;
continue;
}
break;
}
return result;
}

Loading…
Cancel
Save