#include <evo/commandline.h>
template<class ConsoleT = Console>
struct evo::CommandLineT< ConsoleT >::Command
Used to set command options and arguments.
|
virtual | ~Command () |
| Destructor. More...
|
|
virtual Option & | add (const String &str)=0 |
| Parse input string and add an option or argument as described to command. More...
|
|
virtual Option & | addarg (const String &key, const String &helpname, const String &help)=0 |
| Add a positional argument to command. More...
|
|
virtual Option & | addarg (const String &key, const String &help)=0 |
| Add a positional argument to command. More...
|
|
virtual void | addflag (const String &names, const String &key, const String &help)=0 |
| Add an option flag to command. More...
|
|
virtual void | addflag (const String &names, const String &help)=0 |
| Add an option flag to command. More...
|
|
virtual Option & | addopt (const String &names, const String &key, const String &helpname, const String &help)=0 |
| Add an option that stores a value to command. More...
|
|
virtual Option & | addopt (const String &names, const String &helpname, const String &help)=0 |
| Add an option that stores a value to command. More...
|
|
virtual Option & | addopt (const String &names, const String &help)=0 |
| Add an option that stores a value to command. More...
|
|
virtual void | addsep ()=0 |
| Add an options separator in usage help. More...
|
|
◆ ~Command()
◆ add()
Parse input string and add an option or argument as described to command.
- This calls addsep(), addflag(), addopt(), or addarg() depending on input
- Use empty string to add an option separator
- Option flag syntax:
NAMES HELP
- Option with value syntax:
NAMES VALUE HELP
- Argument syntax:
NAME HELP
- Where:
NAMES
is a comma and/or space separated list of short or long option names (usually short first), the last of which is used as the option key
(without dash or double dash prefix)
HELP
is a help string for this option/argument (may contain newlines) – at least two spaces are required before this
VALUE
is the name of the option value to show in usage help (also called helpname
)
NAME
is the argument name to show in usage help
- Parameters
-
◆ addarg() [1/2]
Add a positional argument to command.
- Multiple values for an argument are stored with a semicolon separator (i.e. they stack)
- Parameters
-
key | Key to store option flag under when parsing arguments, example: outfile |
helpname | Name to represent argument value shown with usage help (usually in caps), example: OUTFILE |
help | Help string for this option to show with usage help, example: Output file to use |
- Returns
- Option object for setting additonal argument information
◆ addarg() [2/2]
Add a positional argument to command.
- The key is also used as
helpname
- Multiple values for an argument are stored with a semicolon separator (i.e. they stack)
- Parameters
-
key | Key to store option flag under when parsing arguments, example: outfile |
help | Help string for this option to show with usage help, example: Output file to use |
- Returns
- Option object for setting additonal argument information
◆ addflag() [1/2]
Add an option flag to command.
- When parsing repeated flags, the occurrences are counted and stored as a string value (if more than 1 occurrence)
- Special option '-' (just a single dash) can be added here, this usually means read from stdin instead of a file
- Parameters
-
names | Option names to look for when parsing arguments (comma separated) |
key | Key to store option flag under when parsing arguments |
help | Help string for this option |
◆ addflag() [2/2]
virtual void addflag |
( |
const String & |
names, |
|
|
const String & |
help |
|
) |
| |
|
pure virtual |
Add an option flag to command.
- The last name is used as the option
key
(without dash or double dash prefix)
- When parsing repeated flags, the occurrences are counted and stored as a string value (if more than 1 occurrence)
- Special option '-' (just a single dash) can be added here, this usually means read from stdin instead of a file
- Parameters
-
names | Option names to look for when parsing arguments (comma separated) |
help | Help string for this option |
◆ addopt() [1/3]
Add an option that stores a value to command.
- Multiple values allowed for the same option are stored with a semicolon separator
- When parsing repeated options, previous values for that option are overwritten by default
- Parameters
-
names | Option names to look for when parsing arguments (comma separated), example: -v,–verbose |
key | Key to store option flag under when parsing arguments, example: outfile |
helpname | Name to represent option value shown with usage help (usually in caps), example: OUTFILE |
help | Help string for this option to show with usage help, example: Output file to use |
- Returns
- Option object for setting additonal information
◆ addopt() [2/3]
Add an option that stores a value to command.
- The last name is used as the option
key
(without dash or double dash prefix)
- Multiple values allowed for the same option are stored with a semicolon separator
- When parsing repeated options, previous values for that option are overwritten by default
- Parameters
-
names | Option names to look for when parsing arguments (comma separated), example: -v,–verbose |
helpname | Name to represent option value shown with usage help (usually in caps), example: OUTFILE |
help | Help string for this option to show with usage help, example: Output file to use |
- Returns
- Option object for setting additonal information
◆ addopt() [3/3]
Add an option that stores a value to command.
- The last name is used as both the option
key
and helpname
(without dash or double dash prefix)
- Multiple values allowed for the same option are stored with a semicolon separator
- When parsing repeated options, previous values for that option are overwritten by default
- Parameters
-
names | Option names to look for when parsing arguments (comma separated), example: -v,–verbose |
help | Help string for this option to show with usage help, example: Output file to use |
- Returns
- Option object for setting additonal information
◆ addsep()
Add an options separator in usage help.
- This adds a blank line before the next option in usage help
- This is useful for visually grouping related options in usage help
The documentation for this struct was generated from the following file: