Browse Source

Do not display help for hidden modules

tempestpy_adaptions
Matthias Volk 7 years ago
parent
commit
e951265839
  1. 16
      src/storm/settings/SettingsManager.cpp
  2. 9
      src/storm/settings/SettingsManager.h

16
src/storm/settings/SettingsManager.cpp

@ -178,7 +178,10 @@ namespace storm {
// Find longest option name.
uint_fast64_t maxLength = getPrintLengthOfLongestOption();
for (auto const& moduleName : this->moduleNames) {
// Only print for visible modules.
if (hasModule(moduleName, true)) {
printHelpForModule(moduleName, maxLength);
};
}
} else {
// Create a regular expression from the input hint.
@ -192,6 +195,8 @@ namespace storm {
uint_fast64_t maxLengthModules = 0;
for (auto const& moduleName : this->moduleNames) {
if (std::regex_search(moduleName, hintRegex)) {
if (hasModule(moduleName, true)) {
// Only consider visible modules.
matchingModuleNames.push_back(moduleName);
maxLengthModules = std::max(maxLengthModules, getPrintLengthOfLongestOption(moduleName));
@ -200,6 +205,7 @@ namespace storm {
printedOptions.insert(optionIterator->second.begin(), optionIterator->second.end());
}
}
}
// Try to match the regular expression against the known options.
std::vector<std::shared_ptr<Option>> matchingOptions;
@ -282,8 +288,8 @@ namespace storm {
std::unique_ptr<modules::ModuleSettings> const& settings = iterator->second;
if (doRegister) {
// Now register the options of the module.
this->moduleOptions.emplace(moduleName, std::vector<std::shared_ptr<Option>>());
// Now register the options of the module.
for (auto const& option : settings->getOptions()) {
this->addOption(option);
}
@ -318,6 +324,14 @@ namespace storm {
}
}
bool SettingsManager::hasModule(std::string const& moduleName, bool checkHidden) const {
if (checkHidden) {
return this->moduleOptions.find(moduleName) != this->moduleOptions.end();
} else {
return this->modules.find(moduleName) != this->modules.end();
}
}
modules::ModuleSettings const& SettingsManager::getModule(std::string const& moduleName) const {
auto moduleIterator = this->modules.find(moduleName);
STORM_LOG_THROW(moduleIterator != this->modules.end(), storm::exceptions::IllegalFunctionCallException, "Cannot retrieve unknown module '" << moduleName << "'.");

9
src/storm/settings/SettingsManager.h

@ -103,6 +103,15 @@ namespace storm {
*/
void addModule(std::unique_ptr<modules::ModuleSettings>&& moduleSettings, bool doRegister = true);
/*!
* Checks whether the module with the given name exists.
*
* @param moduleName The name of the module to search.
* @param checkHidden If true hidden modules are included in the search.
* @return True iff the module exists.
*/
bool hasModule(std::string const& moduleName, bool checkHidden = false) const;
/*!
* Retrieves the settings of the module with the given name.
*

Loading…
Cancel
Save