Main class of argument parser hold all user arguments from code and orchestrate other classes in order to parse command line input.
More...
#include <argparse.h>
|
| static std::string | TrimTrailingSpacesPerLine (const std::string &text) |
| | Removes trailing spaces/tabs from every line of the help text.
|
Main class of argument parser hold all user arguments from code and orchestrate other classes in order to parse command line input.
Definition at line 1239 of file argparse.h.
◆ ArgumentParser()
| ARGPARSE_NAMESPACE_NAME::ArgumentParser::ArgumentParser |
( |
const std::string & | name | ) |
|
|
inlinenoexcept |
Constructor for ArgumentParser.
- Parameters
-
| name | Program name which will appear in auto-generated help |
Definition at line 1244 of file argparse.h.
◆ _unknownArgumentHit()
| bool ARGPARSE_NAMESPACE_NAME::ArgumentParser::_unknownArgumentHit |
( |
ArgumentsObject & | argObj, |
|
|
const size_t | positionInInput, |
|
|
size_t & | currentArgumentObjectIndex, |
|
|
bool & | positionalArgsEndFlag, |
|
|
const std::string & | el ) |
|
inline |
function which resolves unknown arguments presence
- Parameters
-
| argObj | |
| positionInInput | |
| currentArgumentObjectIndex | |
| positionalArgsEndFlag | |
| el | |
- Returns
- bool - true for ignoring, false for stopping parse
Definition at line 1629 of file argparse.h.
◆ AddArgument()
| void ARGPARSE_NAMESPACE_NAME::ArgumentParser::AddArgument |
( |
const Argument & | arg | ) |
|
|
inline |
Function to add arguments specification to command line parser.
- Parameters
-
Definition at line 1319 of file argparse.h.
◆ GetHelp()
| std::string ARGPARSE_NAMESPACE_NAME::ArgumentParser::GetHelp |
( |
size_t | width = kHelpWidth, |
|
|
size_t | nameWidthPercent = kHelpNameWidthPercent ) |
|
inline |
Function to get help string.
- Parameters
-
| width | current terminal width (80 by default) |
| nameWidthPercent | percentage of current width, for naming parameters (30 by default) |
- Returns
- help string with proper new lines
Definition at line 1664 of file argparse.h.
◆ ParseArgs() [1/2]
| ArgumentsObject ARGPARSE_NAMESPACE_NAME::ArgumentParser::ParseArgs |
( |
const int | argc, |
|
|
char ** | argv ) |
|
inline |
This function just converts argc and argv to vector of token.
- Parameters
-
| argc | count of arguments |
| argv | pointer to array of char* |
- Returns
- ArgumentsObject, which contains valid ArgumentParsed if parsing successful or information about errors if not
Definition at line 1648 of file argparse.h.
◆ ParseArgs() [2/2]
| ArgumentsObject ARGPARSE_NAMESPACE_NAME::ArgumentParser::ParseArgs |
( |
const std::vector< std::string > & | args | ) |
|
|
inline |
Main function of parsing argument.
- Parameters
-
| args | vector of input tokens |
- Returns
- ArgumentsObject, which contains valid ArgumentParsed if parsing successful or information about errors if not
Definition at line 1361 of file argparse.h.
◆ SetAddHelp()
| ArgumentParser & ARGPARSE_NAMESPACE_NAME::ArgumentParser::SetAddHelp |
( |
bool | addHelp | ) |
|
|
inlinenoexcept |
Add a - h / –help option to the parser.
- Parameters
-
| addHelp | Flag to add or not (true by default) |
- Returns
- reference to current parser
Definition at line 1279 of file argparse.h.
◆ SetAllowAbbrev()
| ArgumentParser & ARGPARSE_NAMESPACE_NAME::ArgumentParser::SetAllowAbbrev |
( |
bool | allowAbbrev | ) |
|
|
inlinenoexcept |
Allows long options to be abbreviated if the abbreviation is unambiguous.
- Parameters
-
| allowAbbrev | bool value true for allow (true by default) |
- Returns
- reference to current parser
Definition at line 1260 of file argparse.h.
◆ SetDescription()
| ArgumentParser & ARGPARSE_NAMESPACE_NAME::ArgumentParser::SetDescription |
( |
const std::string & | description | ) |
|
|
inlinenoexcept |
Overload default description for auto-generated command line.
- Parameters
-
| description | Text to display before the argument help ("" by default) |
- Returns
- reference to current parser
Definition at line 1251 of file argparse.h.
◆ SetEpilogue()
| ArgumentParser & ARGPARSE_NAMESPACE_NAME::ArgumentParser::SetEpilogue |
( |
const std::string & | epilogue | ) |
|
|
inlinenoexcept |
This function allows to set final message after program description and before argument list description.
- Parameters
-
| epilogue | string of epilogue. Automatically adjusting to screen size. (empty by default) |
- Returns
- reference to current parser
Definition at line 1291 of file argparse.h.
◆ SetIgnoreUnknownArgs()
| ArgumentParser & ARGPARSE_NAMESPACE_NAME::ArgumentParser::SetIgnoreUnknownArgs |
( |
bool | ignoreUnknownArgs | ) |
|
|
inlinenoexcept |
Setter to ignore unknown argument while parsing.
If false parsing will be failed if parser detected unknown argument.
- Parameters
-
| ignoreUnknownArgs | bool value for ignore or not (false by default) |
- Returns
- reference to current parser
Definition at line 1270 of file argparse.h.
◆ SetPrefixChars()
| ArgumentParser & ARGPARSE_NAMESPACE_NAME::ArgumentParser::SetPrefixChars |
( |
const char | charSym | ) |
|
|
inlinenoexcept |
Function to override default prefix.
Be careful when you choosing prefix. Single prefix will be used for short names of named argument. Double prefix - for long names. Positional arguments have no any prefix
- Parameters
-
| charSym | character which will be used for prefix. ('-' by default) |
- Returns
Definition at line 1311 of file argparse.h.
◆ SetUsage()
| ArgumentParser & ARGPARSE_NAMESPACE_NAME::ArgumentParser::SetUsage |
( |
const std::string & | usage | ) |
|
|
inlinenoexcept |
Program usage examples.
- Parameters
-
| usage | the string describing the program usage. (default: generated from arguments added to parser) |
- Returns
- reference to current parser
Definition at line 1300 of file argparse.h.
◆ TrimTrailingSpacesPerLine()
| std::string ARGPARSE_NAMESPACE_NAME::ArgumentParser::TrimTrailingSpacesPerLine |
( |
const std::string & | text | ) |
|
|
inlinestatic |
Removes trailing spaces/tabs from every line of the help text.
The column-based layout leaves padding at the end of many lines; this keeps the rendered help clean without touching the wrapping logic.
- Parameters
-
| text | help text possibly containing trailing whitespace |
- Returns
- text with per-line trailing whitespace removed
Definition at line 1739 of file argparse.h.
The documentation for this class was generated from the following file: