Browse Source

Do not display help for hidden modules

main
Matthias Volk 8 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. // 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) {
// Only print for visible modules.
if (hasModule(moduleName, true)) {
printHelpForModule(moduleName, maxLength); printHelpForModule(moduleName, maxLength);
};
} }
} else { } else {
// Create a regular expression from the input hint. // Create a regular expression from the input hint.
@ -192,6 +195,8 @@ 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)) {
if (hasModule(moduleName, true)) {
// Only consider visible modules.
matchingModuleNames.push_back(moduleName); matchingModuleNames.push_back(moduleName);
maxLengthModules = std::max(maxLengthModules, getPrintLengthOfLongestOption(moduleName)); maxLengthModules = std::max(maxLengthModules, getPrintLengthOfLongestOption(moduleName));
@ -200,6 +205,7 @@ namespace storm {
printedOptions.insert(optionIterator->second.begin(), optionIterator->second.end()); printedOptions.insert(optionIterator->second.begin(), optionIterator->second.end());
} }
} }
}
// Try to match the regular expression against the known options. // Try to match the regular expression against the known options.
std::vector<std::shared_ptr<Option>> matchingOptions; std::vector<std::shared_ptr<Option>> matchingOptions;
@ -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);
} }
@ -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 { modules::ModuleSettings const& SettingsManager::getModule(std::string const& moduleName) const {
auto moduleIterator = this->modules.find(moduleName); auto moduleIterator = this->modules.find(moduleName);
STORM_LOG_THROW(moduleIterator != this->modules.end(), storm::exceptions::IllegalFunctionCallException, "Cannot retrieve unknown module '" << 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); 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