#include <CommandLine.h>
|
| void | printCommands (const String &onlyForCommand, size_t screenColumns, size_t nameColumns, const Strings &sortedCommands, size_t helpTextColumns) const |
| |
| void | printOptions (const String &onlyForCommand, size_t screenColumns, size_t nameColumns, const Strings &sortedOptions, size_t helpTextColumns) const |
| |
| | CommandLine (const String &programVersion, const String &description, const String &commandLinePrototype) |
| |
| void | defineOption (const String &fullName, const String &shortName, const Visibility &useForCommands, const String &help) |
| |
| void | defineParameter (const String &fullName, const String &shortName, const String &valueName, const String &validateValue, const Visibility &useForCommands, const String &defaultValue, const String &help) |
| |
| void | defineArgument (const String &fullName, const String &helpText) |
| |
| void | init (size_t argc, const char **argv) |
| |
| String | getOptionValue (const String &name) const |
| |
| bool | hasOption (const String &name) const |
| |
| void | setOptionValue (const String &name, const String &value="yes") |
| |
| const Strings & | arguments () const |
| |
| void | printHelp (size_t screenColumns) const |
| |
| void | printHelp (const String &onlyForCommand, size_t screenColumns) const |
| |
| void | printVersion () const |
| |
◆ CommandLine()
| sptk::CommandLine::CommandLine |
( |
const String & |
programVersion, |
|
|
const String & |
description, |
|
|
const String & |
commandLinePrototype |
|
) |
| |
Constructor
- Parameters
-
| programVersion | Program version and copyright message (forhelp only). |
| description | Program description (forhelp only). |
| commandLinePrototype | Command line prototype (forhelp only). |
◆ arguments()
| const Strings & sptk::CommandLine::arguments |
( |
| ) |
const |
Returns list of command line arguments
◆ defineArgument()
| void sptk::CommandLine::defineArgument |
( |
const String & |
fullName, |
|
|
const String & |
helpText |
|
) |
| |
Defines command line argument/command.
- Parameters
-
| fullName | Argument/command name |
| helpText | Help (description) for the element |
◆ defineOption()
| void sptk::CommandLine::defineOption |
( |
const String & |
fullName, |
|
|
const String & |
shortName, |
|
|
const Visibility & |
useForCommands, |
|
|
const String & |
help |
|
) |
| |
Defines command line option
An option doesn't expect a value. If it is present in command line, it assumes value 'yes'. Otherwise it has value 'no'.
- Parameters
-
| fullName | Element name |
| shortName | Short element name (single character, options only) |
| useForCommands | Element visibility for a command (options only) |
| help | Help (description) for the element |
◆ defineParameter()
| void sptk::CommandLine::defineParameter |
( |
const String & |
fullName, |
|
|
const String & |
shortName, |
|
|
const String & |
valueName, |
|
|
const String & |
validateValue, |
|
|
const Visibility & |
useForCommands, |
|
|
const String & |
defaultValue, |
|
|
const String & |
help |
|
) |
| |
Defines command line parameter
- Parameters
-
| fullName | Element name |
| shortName | Short element name (single character, options only) |
| valueName | Value name |
| validateValue | Value validation regular expression |
| useForCommands | Element visibility for a command (options only) |
| defaultValue | Option default value |
| help | Help (description) for the element |
◆ getOptionValue()
| String sptk::CommandLine::getOptionValue |
( |
const String & |
name | ) |
const |
Returns actual option value
- Parameters
-
◆ hasOption()
| bool sptk::CommandLine::hasOption |
( |
const String & |
name | ) |
const |
Returns true if actual command line contains option
- Parameters
-
◆ init()
| void sptk::CommandLine::init |
( |
size_t |
argc, |
|
|
const char ** |
argv |
|
) |
| |
Parses actual command line arguments.
Should be executed after any define* methods of this class.
- Parameters
-
| argc | Number of command line arguments (from main(argc,argv)). |
| argv | Command line arguments (from main(argc,argv)). |
◆ preprocessArguments()
| static Strings sptk::CommandLine::preprocessArguments |
( |
const std::vector< const char * > & |
argv | ) |
|
|
static |
Preprocess command line arguments
- Parameters
-
| argc | Number of command line arguments |
| argv | Command line arguments |
- Returns
- preprocessed command line arguments
◆ printCommands()
| void sptk::CommandLine::printCommands |
( |
const String & |
onlyForCommand, |
|
|
size_t |
screenColumns, |
|
|
size_t |
nameColumns, |
|
|
const Strings & |
sortedCommands, |
|
|
size_t |
helpTextColumns |
|
) |
| const |
Print help on commands
- Parameters
-
| onlyForCommand | Optional: if not empty then print only this command help |
| screenColumns | Screen width in columns |
| nameColumns | Number of columns for command names |
| sortedCommands | Sorted command list |
| helpTextColumns | Number of columns for help text |
◆ printHelp() [1/2]
| void sptk::CommandLine::printHelp |
( |
const String & |
onlyForCommand, |
|
|
size_t |
screenColumns |
|
) |
| const |
Prints help for a given command/argument
- Parameters
-
| onlyForCommand | Command to print help for |
| screenColumns | Screen width in columns |
◆ printHelp() [2/2]
| void sptk::CommandLine::printHelp |
( |
size_t |
screenColumns | ) |
const |
Prints full help
- Parameters
-
| screenColumns | Screen width in columns |
◆ printLine()
| static void sptk::CommandLine::printLine |
( |
const String & |
ch, |
|
|
size_t |
count |
|
) |
| |
|
static |
prints a line of characters
- Parameters
-
| ch | Character to print |
| count | Number of characters to print |
◆ printOptions()
| void sptk::CommandLine::printOptions |
( |
const String & |
onlyForCommand, |
|
|
size_t |
screenColumns, |
|
|
size_t |
nameColumns, |
|
|
const Strings & |
sortedOptions, |
|
|
size_t |
helpTextColumns |
|
) |
| const |
Print help on options
- Parameters
-
| onlyForCommand | Optional: if not empty then print only this command help |
| screenColumns | Screen width in columns |
| nameColumns | Number of columns for option names |
| sortedOptions | Sorted option list |
| helpTextColumns | Number of columns for help text |
◆ printVersion()
| void sptk::CommandLine::printVersion |
( |
| ) |
const |
◆ rewriteArguments()
| static Strings sptk::CommandLine::rewriteArguments |
( |
const Strings & |
arguments | ) |
|
|
static |
Re-write command line arguments
- Parameters
-
| arguments | Command line arguments |
- Returns
- re-written command line arguments
◆ setOptionValue()
| void sptk::CommandLine::setOptionValue |
( |
const String & |
name, |
|
|
const String & |
value = "yes" |
|
) |
| |
Re-defines actual option value
- Parameters
-
| name | Option name |
| value | Option value |
The documentation for this class was generated from the following file: