Gromacs
2025.0-dev-20241009-5c23d5f
|
#include <gromacs/commandline/cmdlinehelpcontext.h>
Context information for writing out command-line help.
This class wraps a HelpWriterContext, extending it with information specific for command-line help export. This way, code using only the routines in the onlinehelp module is not exposed to extra features of the command-line help export.
Copying a context works like with HelpWriterContext: the output file and most state is shared. However, setModuleDisplayName() and setShowHidden() can be set independently for the child context. Defaults for these options are inherited from the parent.
Classes | |
class | Impl |
Private implementation class for CommandLineHelpContext. More... | |
Public Member Functions | |
CommandLineHelpContext (TextWriter *writer, HelpOutputFormat format, const HelpLinks *links, const std::string &programName) | |
Creates a context for help export. More... | |
CommandLineHelpContext (const HelpWriterContext &writerContext) | |
Creates a context for a particular HelpWriterContext. | |
CommandLineHelpContext (ShellCompletionWriter *writer) | |
Creates a context for shell completion. | |
CommandLineHelpContext (const CommandLineHelpContext &other) | |
Creates a copy of the context. | |
CommandLineHelpContext (CommandLineHelpContext &&other) noexcept | |
Moves the context. | |
CommandLineHelpContext & | operator= (CommandLineHelpContext &&other) noexcept |
Move-assigns the context. | |
void | setModuleDisplayName (const std::string &name) |
Sets a display name for the module for which help is being written. More... | |
void | setShowHidden (bool bHidden) |
Sets whether hidden options should be shown in help output. | |
void | enterSubSection (const std::string &title) |
Creates a subsection in the output help. More... | |
const HelpWriterContext & | writerContext () const |
Returns the lower-level context for writing the help. | |
const char * | moduleDisplayName () const |
Returns a display name for the module for which help is being written. More... | |
bool | showHidden () const |
Returns whether hidden options should be shown in help output. | |
bool | isCompletionExport () const |
Returns whether this context is for exporting shell completions. | |
ShellCompletionWriter & | shellCompletionWriter () const |
Returns the shell completion writer for this context. More... | |
gmx::CommandLineHelpContext::CommandLineHelpContext | ( | TextWriter * | writer, |
HelpOutputFormat | format, | ||
const HelpLinks * | links, | ||
const std::string & | programName | ||
) |
Creates a context for help export.
Wraps the constructor of HelpWriterContext.
void gmx::CommandLineHelpContext::enterSubSection | ( | const std::string & | title | ) |
Creates a subsection in the output help.
[in] | title | Title for the subsection. |
std::bad_alloc | if out of memory. |
FileIOError | on any I/O error. |
Writes title
using writeTitle() and makes any further writeTitle() calls write headings one level deeper.
Typical use for writing a subsection is to create a copy of the context for the parent section, and then call enterSubSection() on the copy. The whole subsection should be written out using the returned context before calling any further methods in the parent context.
This method is only necessary if the subsection will contain further subsections. If there is only one level of subsections, it is possible to use writeTitle() directly.
const char * gmx::CommandLineHelpContext::moduleDisplayName | ( | ) | const |
Returns a display name for the module for which help is being written.
Does not throw.
void gmx::CommandLineHelpContext::setModuleDisplayName | ( | const std::string & | name | ) |
Sets a display name for the module for which help is being written.
std::bad_alloc | if out of memory. |
ShellCompletionWriter & gmx::CommandLineHelpContext::shellCompletionWriter | ( | ) | const |
Returns the shell completion writer for this context.
Can only be called if isCompletionExport() returns true
.