From e95126583990a30776afb2779fe5a7a0907997b8 Mon Sep 17 00:00:00 2001 From: Matthias Volk Date: Fri, 26 Jan 2018 13:48:53 +0100 Subject: [PATCH] Do not display help for hidden modules --- src/storm/settings/SettingsManager.cpp | 30 +++++++++++++++++++------- src/storm/settings/SettingsManager.h | 11 +++++++++- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/storm/settings/SettingsManager.cpp b/src/storm/settings/SettingsManager.cpp index 188d1cba2..eb8e29c99 100644 --- a/src/storm/settings/SettingsManager.cpp +++ b/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) { - printHelpForModule(moduleName, maxLength); + // Only print for visible modules. + if (hasModule(moduleName, true)) { + printHelpForModule(moduleName, maxLength); + }; } } else { // Create a regular expression from the input hint. @@ -192,12 +195,15 @@ namespace storm { uint_fast64_t maxLengthModules = 0; for (auto const& moduleName : this->moduleNames) { 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 const& settings = iterator->second; if (doRegister) { - // Now register the options of the module. this->moduleOptions.emplace(moduleName, std::vector>()); + // Now register the options of the module. for (auto const& option : settings->getOptions()) { this->addOption(option); } @@ -317,6 +323,14 @@ namespace storm { 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 { auto moduleIterator = this->modules.find(moduleName); diff --git a/src/storm/settings/SettingsManager.h b/src/storm/settings/SettingsManager.h index 72ee1bd37..1ccb10bfa 100644 --- a/src/storm/settings/SettingsManager.h +++ b/src/storm/settings/SettingsManager.h @@ -102,7 +102,16 @@ namespace storm { * @param moduleSettings The settings of the module to add. */ void addModule(std::unique_ptr&& 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. *