*/
/*! \brief
- * Implements a CommandLineModuleInterface, given a function with C/C++ main()
+ * Implements a ICommandLineModule, given a function with C/C++ main()
* signature.
*/
-class CMainCommandLineModule : public CommandLineModuleInterface
+class CMainCommandLineModule : public ICommandLineModule
{
public:
//! \copydoc gmx::CommandLineModuleManager::CMainFunction
CommandLineCommonOptionsHolder::CommandLineCommonOptionsHolder()
: options_(NULL, NULL), bHelp_(false), bHidden_(false),
bQuiet_(false), bVersion_(false), bCopyright_(true),
- niceLevel_(19), bBackup_(true), bFpexcept_(false), debugLevel_(0)
+ niceLevel_(19), bNiceSet_(false), bBackup_(true), bFpexcept_(false),
+ debugLevel_(0)
{
binaryInfoSettings_.copyright(true);
}
.description("Print extended version information and quit"));
options_.addOption(BooleanOption("copyright").store(&bCopyright_)
.description("Print copyright information on startup"));
- options_.addOption(IntegerOption("nice").store(&niceLevel_)
+ options_.addOption(IntegerOption("nice").store(&niceLevel_).storeIsSet(&bNiceSet_)
.description("Set the nicelevel (default depends on command)"));
options_.addOption(BooleanOption("backup").store(&bBackup_)
.description("Write backups if output files exist"));
void CommandLineCommonOptionsHolder::adjustFromSettings(
const CommandLineModuleSettings &settings)
{
- if (!options_.isSet("nice"))
+ if (!bNiceSet_)
{
niceLevel_ = settings.defaultNiceLevel();
}
* options). Also finds the module that should be run and the
* arguments that should be passed to it.
*/
- CommandLineModuleInterface *
+ ICommandLineModule *
processCommonOptions(CommandLineCommonOptionsHolder *optionsHolder,
int *argc, char ***argv);
*/
CommandLineHelpModule *helpModule_;
//! If non-NULL, run this module in single-module mode.
- CommandLineModuleInterface *singleModule_;
+ ICommandLineModule *singleModule_;
//! Stores the value set with setQuiet().
bool bQuiet_;
HelpTopicPointer helpTopic(helpModule_->createModuleHelpTopic(*module));
modules_.insert(std::make_pair(std::string(module->name()),
move(module)));
- helpModule_->addTopic(move(helpTopic));
+ helpModule_->addTopic(move(helpTopic), false);
}
void CommandLineModuleManager::Impl::ensureHelpModuleExists()
return modules_.find(name);
}
-CommandLineModuleInterface *
+ICommandLineModule *
CommandLineModuleManager::Impl::processCommonOptions(
CommandLineCommonOptionsHolder *optionsHolder, int *argc, char ***argv)
{
// Check if we are directly invoking a certain module.
- CommandLineModuleInterface *module = singleModule_;
+ ICommandLineModule *module = singleModule_;
// TODO: It would be nice to propagate at least the -quiet option to
// the modules so that they can also be quiet in response to this.
impl_->bQuiet_ = bQuiet;
}
-void CommandLineModuleManager::setOutputRedirect(File *output)
+void CommandLineModuleManager::setOutputRedirector(
+ IFileOutputRedirector *output)
{
impl_->ensureHelpModuleExists();
- impl_->helpModule_->setOutputRedirect(output);
+ impl_->helpModule_->setOutputRedirector(output);
}
-void CommandLineModuleManager::setSingleModule(CommandLineModuleInterface *module)
+void CommandLineModuleManager::setSingleModule(ICommandLineModule *module)
{
impl_->singleModule_ = module;
}
void CommandLineModuleManager::addHelpTopic(HelpTopicPointer topic)
{
impl_->ensureHelpModuleExists();
- impl_->helpModule_->addTopic(move(topic));
+ impl_->helpModule_->addTopic(move(topic), true);
}
int CommandLineModuleManager::run(int argc, char *argv[])
{
- CommandLineModuleInterface *module;
+ ICommandLineModule *module;
const bool bMaster = (gmx_node_rank() == 0);
bool bQuiet = impl_->bQuiet_ || !bMaster;
CommandLineCommonOptionsHolder optionsHolder;
// static
int CommandLineModuleManager::runAsMainSingleModule(
- int argc, char *argv[], CommandLineModuleInterface *module)
+ int argc, char *argv[], ICommandLineModule *module)
{
CommandLineProgramContext &programContext = gmx::initForCommandLine(&argc, &argv);
try