|
#include <CommandLine.h>
Public Types | |
| enum class | Type { IS_UNKNOWN , IS_COMMAND , IS_OPTION , IS_VALUE_OPTION } |
Public Member Functions | |
| CommandLineElement (const String &name, const String &shortName, const String &help, const Visibility &useWithCommands) | |
| virtual | ~CommandLineElement ()=default |
| virtual Type | type () const |
| virtual String | name () const |
| virtual String | shortName () const |
| virtual bool | hasValue () const |
| virtual void | validate (const String &value) const |
| virtual String | printableName () const |
| bool | useWithCommand (const String &command) const |
| void | formatHelp (size_t textWidth, Strings &formattedText) const |
| void | printHelp (size_t nameWidth, size_t textWidth, const String &optionDefaultValue) const |
Command line element that could be argument/command, option, or option with value
|
strong |
| sptk::CommandLine::CommandLineElement::CommandLineElement | ( | const String & | name, |
| const String & | shortName, | ||
| const String & | help, | ||
| const Visibility & | useWithCommands | ||
| ) |
Constructor
| name | Element name |
| shortName | Short element name (single character, options only) |
| help | Help (description) for the element |
| useWithCommands | Element visibility for a command (options only) |
|
virtualdefault |
Destructor
| void sptk::CommandLine::CommandLineElement::formatHelp | ( | size_t | textWidth, |
| Strings & | formattedText | ||
| ) | const |
Formats element help for printout
| textWidth | Help text width |
| formattedText | Formatted help text |
|
virtual |
Returns true if element expects value
Reimplemented in sptk::CommandLine::CommandLineOption, and sptk::CommandLine::CommandLineParameter.
|
virtual |
Returns element name
|
virtual |
Returns element name in help print format
Reimplemented in sptk::CommandLine::CommandLineOption, and sptk::CommandLine::CommandLineParameter.
| void sptk::CommandLine::CommandLineElement::printHelp | ( | size_t | nameWidth, |
| size_t | textWidth, | ||
| const String & | optionDefaultValue | ||
| ) | const |
Prints element help
| nameWidth | Optional name width |
| textWidth | Help text width |
| optionDefaultValue | Option default value (if any) |
| output | Optinal output stream |
|
virtual |
Returns element short name
|
virtual |
Returns element type
Reimplemented in sptk::CommandLine::CommandLineOption, and sptk::CommandLine::CommandLineParameter.
| bool sptk::CommandLine::CommandLineElement::useWithCommand | ( | const String & | command | ) | const |
Returns true if element may be used with command (options only)
|
virtual |
Validates given value (for elements that provide validation)
Throws an exception if the value is invalid
| value | Value to validate |
Reimplemented in sptk::CommandLine::CommandLineParameter.