Browse Source

Fixed handling of optional arguments.

Missing an optional argument now throws an exception.
tempestpy_adaptions
Matthias Volk 5 years ago
parent
commit
3f717202cd
  1. 16
      src/storm/settings/Argument.cpp
  2. 2
      src/storm/settings/SettingsManager.cpp

16
src/storm/settings/Argument.cpp

@ -171,20 +171,28 @@ namespace storm {
out << std::setw(0) << std::left << "<" << this->getName() << ">";
if (!this->validators.empty() || this->hasDefaultValue) {
out << " (";
bool previousEntry = false;
if (this->getIsOptional()) {
out << "optional";
previousEntry = true;
}
if (!this->validators.empty()) {
if (previousEntry) {
out << "; ";
}
for (uint64_t i = 0; i < this->validators.size(); ++i) {
out << this->validators[i]->toString();
if (i + 1 < this->validators.size()) {
out << ", ";
}
}
if (this->hasDefaultValue) {
out << "; ";
}
previousEntry = true;
}
if (this->hasDefaultValue) {
if (previousEntry) {
out << "; ";
}
out << "default: ";
printValue(out, defaultValue);
}

2
src/storm/settings/SettingsManager.cpp

@ -491,7 +491,7 @@ namespace storm {
// In case there are optional arguments that were not set, we set them to their default value.
for (uint_fast64_t i = argumentCache.size(); i < option->getArgumentCount(); ++i) {
ArgumentBase& argument = option->getArgument(i);
STORM_LOG_THROW(argument.getHasDefaultValue() || argument.getIsOptional(), storm::exceptions::OptionParserException, "Non-optional argument <" << argument.getName() << "> of option:\n" << *option);
STORM_LOG_THROW(argument.getIsOptional(), storm::exceptions::OptionParserException, "Non-optional argument <" << argument.getName() << "> of option:\n" << *option);
argument.setFromDefaultValue();
}

Loading…
Cancel
Save