Gromacs  2020.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions
gmx::CommandLineHelpModule Class Reference

#include <gromacs/commandline/cmdlinehelpmodule.h>

+ Inheritance diagram for gmx::CommandLineHelpModule:
+ Collaboration diagram for gmx::CommandLineHelpModule:


Command-line module for producing help.

This module implements the 'help' subcommand that is automatically added by CommandLineModuleManager.

Public Member Functions

 CommandLineHelpModule (const IProgramContext &programContext, const std::string &binaryName, const CommandLineModuleMap &modules, const CommandLineModuleGroupList &groups)
 Creates a command-line help module. More...
HelpTopicPointer createModuleHelpTopic (const ICommandLineModule &module) const
 Creates a help topic for a command-line module. More...
void addTopic (HelpTopicPointer topic, bool bExported)
 Adds a top-level help topic. More...
void setShowHidden (bool bHidden)
 Sets whether hidden options will be shown in help.
void setModuleOverride (const ICommandLineModule &module)
 Sets an override to show the help for the given module. More...
void setOutputRedirector (IFileOutputRedirector *output)
 Sets a file redirector for writing help output. More...
const char * name () const override
 Returns the name of the module.
const char * shortDescription () const override
 Returns a one-line description of the module.
void init (CommandLineModuleSettings *settings) override
 Initializes the module and provides settings for the runner. More...
int run (int argc, char *argv[]) override
 Runs the module with the given arguments. More...
void writeHelp (const CommandLineHelpContext &context) const override
 Prints help for the module. More...

Constructor & Destructor Documentation

gmx::CommandLineHelpModule::CommandLineHelpModule ( const IProgramContext programContext,
const std::string &  binaryName,
const CommandLineModuleMap modules,
const CommandLineModuleGroupList groups 

Creates a command-line help module.

[in]programContextInformation about the running binary.
[in]binaryNameName of the running binary (without Gromacs binary suffix or .exe on Windows).
[in]modulesList of modules for to use for module listings.
[in]groupsList of module groups.
std::bad_allocif out of memory.

Member Function Documentation

void gmx::CommandLineHelpModule::addTopic ( HelpTopicPointer  topic,
bool  bExported 

Adds a top-level help topic.

[in]topicHelp topic to add.
[in]bExportedWhether this topic will be directly exported to the user guide.
std::bad_allocif out of memory.
HelpTopicPointer gmx::CommandLineHelpModule::createModuleHelpTopic ( const ICommandLineModule module) const

Creates a help topic for a command-line module.

[in]moduleModule the create the help topic for.
std::bad_allocif out of memory.

The caller should add the topic using addTopic() if that is desired. This method is provided separately to allow for strong exception safety in CommandLineModuleManager::addModule().

void gmx::CommandLineHelpModule::init ( CommandLineModuleSettings settings)

Initializes the module and provides settings for the runner.

This will be called before run(), and can be used to adjust initialization that the runner does.

This method is currently not called when writing the help.

Implements gmx::ICommandLineModule.

int gmx::CommandLineHelpModule::run ( int  argc,
char *  argv[] 

Runs the module with the given arguments.

[in]argcNumber of elements in argv.
[in]argvCommand-line arguments.
unspecifiedMay throw exceptions to indicate errors.
Exit code for the program.
Return values
0on successful termination.

argv[0] is the name of the module, i.e., the arguments are as if the module was run as a standalone executable.

Implements gmx::ICommandLineModule.

void gmx::CommandLineHelpModule::setModuleOverride ( const ICommandLineModule module)

Sets an override to show the help for the given module.

If called, the help module directly prints the help for the given module when called, skipping any other processing.

void gmx::CommandLineHelpModule::setOutputRedirector ( IFileOutputRedirector output)

Sets a file redirector for writing help output.

Used for unit testing; see CommandLineModuleManager::setOutputRedirector() for more details.

void gmx::CommandLineHelpModule::writeHelp ( const CommandLineHelpContext context) const

Prints help for the module.

[in]contextContext object for writing the help.
std::bad_allocif out of memory.
FileIOErroron any I/O error.

Note that for MPI-enabled builds, this is called only on the master rank.

Implements gmx::ICommandLineModule.

The documentation for this class was generated from the following files: