|
@ -39,6 +39,7 @@ |
|
|
#include "storm/settings/modules/MultiplierSettings.h"
|
|
|
#include "storm/settings/modules/MultiplierSettings.h"
|
|
|
#include "storm/utility/macros.h"
|
|
|
#include "storm/utility/macros.h"
|
|
|
#include "storm/utility/file.h"
|
|
|
#include "storm/utility/file.h"
|
|
|
|
|
|
#include "storm/utility/string.h"
|
|
|
#include "storm/settings/Option.h"
|
|
|
#include "storm/settings/Option.h"
|
|
|
|
|
|
|
|
|
namespace storm { |
|
|
namespace storm { |
|
@ -82,6 +83,18 @@ namespace storm { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SettingsManager::handleUnknownOption(std::string const& optionName, bool isShort) const { |
|
|
|
|
|
std::string optionNameWithDashes = (isShort ? "-" : "--") + optionName; |
|
|
|
|
|
storm::utility::string::SimilarStrings similarStrings(optionNameWithDashes, 0.6, false); |
|
|
|
|
|
for (auto const& longOption : longNameToOptions) { |
|
|
|
|
|
similarStrings.add("--" + longOption.first); |
|
|
|
|
|
} |
|
|
|
|
|
for (auto const& shortOption : shortNameToOptions) { |
|
|
|
|
|
similarStrings.add("-" + shortOption.first); |
|
|
|
|
|
} |
|
|
|
|
|
STORM_LOG_THROW(false, storm::exceptions::OptionParserException, "Unknown option '" << optionNameWithDashes << "'. " << similarStrings.toDidYouMeanString()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void SettingsManager::setFromExplodedString(std::vector<std::string> const& commandLineArguments) { |
|
|
void SettingsManager::setFromExplodedString(std::vector<std::string> const& commandLineArguments) { |
|
|
// In order to assign the parsed arguments to an option, we need to keep track of the "active" option's name.
|
|
|
// In order to assign the parsed arguments to an option, we need to keep track of the "active" option's name.
|
|
|
bool optionActive = false; |
|
|
bool optionActive = false; |
|
@ -111,7 +124,9 @@ namespace storm { |
|
|
// match the long name.
|
|
|
// match the long name.
|
|
|
std::string optionName = currentArgument.substr(2); |
|
|
std::string optionName = currentArgument.substr(2); |
|
|
auto optionIterator = this->longNameToOptions.find(optionName); |
|
|
auto optionIterator = this->longNameToOptions.find(optionName); |
|
|
STORM_LOG_THROW(optionIterator != this->longNameToOptions.end(), storm::exceptions::OptionParserException, "Unknown option '" << optionName << "'."); |
|
|
|
|
|
|
|
|
if (optionIterator == this->longNameToOptions.end()) { |
|
|
|
|
|
handleUnknownOption(optionName, false); |
|
|
|
|
|
} |
|
|
activeOptionIsShortName = false; |
|
|
activeOptionIsShortName = false; |
|
|
activeOptionName = optionName; |
|
|
activeOptionName = optionName; |
|
|
} else { |
|
|
} else { |
|
@ -119,7 +134,9 @@ namespace storm { |
|
|
// match the short name.
|
|
|
// match the short name.
|
|
|
std::string optionName = currentArgument.substr(1); |
|
|
std::string optionName = currentArgument.substr(1); |
|
|
auto optionIterator = this->shortNameToOptions.find(optionName); |
|
|
auto optionIterator = this->shortNameToOptions.find(optionName); |
|
|
STORM_LOG_THROW(optionIterator != this->shortNameToOptions.end(), storm::exceptions::OptionParserException, "Unknown option '" << optionName << "'."); |
|
|
|
|
|
|
|
|
if (optionIterator == this->shortNameToOptions.end()) { |
|
|
|
|
|
handleUnknownOption(optionName, true); |
|
|
|
|
|
} |
|
|
activeOptionIsShortName = true; |
|
|
activeOptionIsShortName = true; |
|
|
activeOptionName = optionName; |
|
|
activeOptionName = optionName; |
|
|
} |
|
|
} |
|
|