yat
0.14.5pre
|
Class for help option. More...
#include <yat/utility/OptionHelp.h>
Public Member Functions | |
OptionHelp (CommandLine &cmd, std::string name="h,help", std::string desc="display this help and exit") | |
Constructor. More... | |
std::string & | post_arguments (void) |
std::string & | synopsis (void) |
std::string & | usage (void) |
bool | value (void) const |
return value | |
std::string | description (void) const |
void | description (const std::string &description) |
set description More... | |
std::string | long_name (void) const |
void | parse (std::vector< std::string >::iterator &, const std::vector< std::string >::iterator &) |
parsing the commandline | |
bool | present (void) const |
Get if option was found in cmd. More... | |
std::string | print (void) |
print help output More... | |
void | reset (void) |
sets present to false | |
char | short_name (void) const |
void | validate (void) |
Validate the Option. More... | |
Protected Member Functions | |
const CommandLine & | cmd (void) const |
Class for help option.
When this option is found in parsing of commandline, it displays a help output and exits. A typical output looks like:
Usage: foo [OPTION]... SYNOPSIS Available options are: -h, --help display this help and exit -v, --verbose explain what is being done Some extra information explaining something.
The output consist of four blocks. The first block can be modified with usage(void) function. The second is block is typically a one-liner explaining the application and can be modified with the synopsis(void) function. The third block contain the description of the different options, see operator<<(std::ostream&, const CommandLine&) for further details. The last block can be modified with post_arguments(void) function.
theplu::yat::utility::OptionHelp::OptionHelp | ( | CommandLine & | cmd, |
std::string | name = "h,help" , |
||
std::string | desc = "display this help and exit" |
||
) |
Constructor.
cmd | Commandline Option is associated with |
name | string such as "help" for –help, "h" for -h or "h,help" (default) for having both short and long option name |
desc | string used in help display |
|
protectedinherited |
|
inherited |
|
inherited |
set description
|
inherited |
std::string& theplu::yat::utility::OptionHelp::post_arguments | ( | void | ) |
Text to be displayed after list of arguments.
|
inherited |
Get if option was found in cmd.
|
inherited |
print help output
This function calls the four virtual private functions print1, print2, print3, and print4. This allows an inherited class to implement one (or several) of these functions and keep the default output of the others. The default behavior is that:
|
inherited |
std::string& theplu::yat::utility::OptionHelp::synopsis | ( | void | ) |
Text to be displayed in help output after usage()
std::string& theplu::yat::utility::OptionHelp::usage | ( | void | ) |
First line to be displayed in help output. Default this string is set to "Usage: <program_name> [OPTION]...\n\n"
|
inherited |
Validate the Option.
This function is called by CommandLine::parse() after all options have been detected and parsed (see Option::parse()).