Gromacs  2025.0-dev-20241009-5c23d5f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Classes | Public Member Functions
gmx::CommandLineHelpContext Class Reference

#include <gromacs/commandline/cmdlinehelpcontext.h>

Description

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.
 
CommandLineHelpContextoperator= (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 HelpWriterContextwriterContext () 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...
 

Constructor & Destructor Documentation

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.

Member Function Documentation

void gmx::CommandLineHelpContext::enterSubSection ( const std::string &  title)

Creates a subsection in the output help.

Parameters
[in]titleTitle for the subsection.
Exceptions
std::bad_allocif out of memory.
FileIOErroron 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.

Exceptions
std::bad_allocif out of memory.
ShellCompletionWriter & gmx::CommandLineHelpContext::shellCompletionWriter ( ) const

Returns the shell completion writer for this context.

Can only be called if isCompletionExport() returns true.


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