Browse Source

Do not display help for hidden modules

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

30
src/storm/settings/SettingsManager.cpp

@ -178,7 +178,10 @@ namespace storm {
// Find longest option name. // Find longest option name.
uint_fast64_t maxLength = getPrintLengthOfLongestOption(); uint_fast64_t maxLength = getPrintLengthOfLongestOption();
for (auto const& moduleName : this->moduleNames) { for (auto const& moduleName : this->moduleNames) {
printHelpForModule(moduleName, maxLength);
// Only print for visible modules.
if (hasModule(moduleName, true)) {
printHelpForModule(moduleName, maxLength);
};
} }
} else { } else {
// Create a regular expression from the input hint. // Create a regular expression from the input hint.
@ -192,12 +195,15 @@ namespace storm {
uint_fast64_t maxLengthModules = 0; uint_fast64_t maxLengthModules = 0;
for (auto const& moduleName : this->moduleNames) { for (auto const& moduleName : this->moduleNames) {
if (std::regex_search(moduleName, hintRegex)) { if (std::regex_search(moduleName, hintRegex)) {
matchingModuleNames.push_back(moduleName);
maxLengthModules = std::max(maxLengthModules, getPrintLengthOfLongestOption(moduleName));
// Add all options of this module to the list of printed options so we don't print them twice.
auto optionIterator = this->moduleOptions.find(moduleName);
printedOptions.insert(optionIterator->second.begin(), optionIterator->second.end());
if (hasModule(moduleName, true)) {
// Only consider visible modules.
matchingModuleNames.push_back(moduleName);
maxLengthModules = std::max(maxLengthModules, getPrintLengthOfLongestOption(moduleName));
// Add all options of this module to the list of printed options so we don't print them twice.
auto optionIterator = this->moduleOptions.find(moduleName);
printedOptions.insert(optionIterator->second.begin(), optionIterator->second.end());
}
} }
} }
@ -282,8 +288,8 @@ namespace storm {
std::unique_ptr<modules::ModuleSettings> const& settings = iterator->second; std::unique_ptr<modules::ModuleSettings> const& settings = iterator->second;
if (doRegister) { if (doRegister) {
// Now register the options of the module.
this->moduleOptions.emplace(moduleName, std::vector<std::shared_ptr<Option>>()); this->moduleOptions.emplace(moduleName, std::vector<std::shared_ptr<Option>>());
// Now register the options of the module.
for (auto const& option : settings->getOptions()) { for (auto const& option : settings->getOptions()) {
this->addOption(option); this->addOption(option);
} }
@ -317,6 +323,14 @@ namespace storm {
addOptionToMap(option->getModuleName() + ":" + option->getShortName(), option, this->shortNameToOptions); addOptionToMap(option->getModuleName() + ":" + option->getShortName(), option, this->shortNameToOptions);
} }
} }
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 { modules::ModuleSettings const& SettingsManager::getModule(std::string const& moduleName) const {
auto moduleIterator = this->modules.find(moduleName); auto moduleIterator = this->modules.find(moduleName);

11
src/storm/settings/SettingsManager.h

@ -102,7 +102,16 @@ namespace storm {
* @param moduleSettings The settings of the module to add. * @param moduleSettings The settings of the module to add.
*/ */
void addModule(std::unique_ptr<modules::ModuleSettings>&& moduleSettings, bool doRegister = true); 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. * Retrieves the settings of the module with the given name.
* *

Loading…
Cancel
Save