E-MailRelay
|
Provides help text for a set of options. More...
#include <goptionsusage.h>
Classes | |
struct | Config |
A configuration structure for G::OptionsUsage. More... | |
Public Types | |
using | SortFn = std::function< bool(const Option &, const Option &)> |
Public Member Functions | |
OptionsUsage (const std::vector< Option > &, SortFn=sort()) | |
Constructor. More... | |
std::string | summary (const Config &, const std::string &exe, const std::string &args={}) const |
Returns a one-line (or line-wrapped) usage summary, as "usage: <exe> <options> <args>". More... | |
std::string | help (const Config &, bool *overflow_p=nullptr) const |
Returns a multi-line string giving help on each option. More... | |
void | output (const Config &, std::ostream &stream, const std::string &exe, const std::string &args={}) const |
Streams out multi-line usage text using summary() and help(). More... | |
Static Public Member Functions | |
static SortFn | sort () |
Returns the default sort function that sorts by level first and then by name. More... | |
Provides help text for a set of options.
If configured with a fixed separator the help() text is formatted as:
Or with a tab separator:
Or with a two-column layout:
Or two-column layout in 'overflow' mode:
Definition at line 64 of file goptionsusage.h.
Definition at line 105 of file goptionsusage.h.
Constructor.
Definition at line 32 of file goptionsusage.cpp.
std::string G::OptionsUsage::help | ( | const Config & | config_in, |
bool * | overflow_p = nullptr |
||
) | const |
Returns a multi-line string giving help on each option.
Use the optional overflow flag if using help() for separate sections that should have the same layout: initialise to false, call help() for each section and discard the result, then call help() again for each section.
Definition at line 69 of file goptionsusage.cpp.
void G::OptionsUsage::output | ( | const Config & | config, |
std::ostream & | stream, | ||
const std::string & | exe, | ||
const std::string & | args = {} |
||
) | const |
Streams out multi-line usage text using summary() and help().
Definition at line 90 of file goptionsusage.cpp.
|
static |
Returns the default sort function that sorts by level first and then by name.
Definition at line 288 of file goptionsusage.cpp.
std::string G::OptionsUsage::summary | ( | const Config & | config_in, |
const std::string & | exe, | ||
const std::string & | args = {} |
||
) | const |
Returns a one-line (or line-wrapped) usage summary, as "usage: <exe> <options> <args>".
The 'args' parameter should represent the non-option arguments (with a leading space), like " <foo> [<bar>]".
Eg:
Definition at line 49 of file goptionsusage.cpp.