Spec
ArgParseOptionStore information for a specific command line option.
Store information for a specific command line option.
| Extends | ArgParseArgument |
|---|---|
| All Extended | ArgParseArgument |
| All Impl'd | AssignableConcept |
| Defined in | <seqan/arg_parse.h> |
| Signature |
class ArgParseOption : ArgParseArgument;
|
Member Function Overview
-
ArgParseOption::ArgParseOption(shortName, longName, helpText, argumentType[, argumentLabel[, isList[, numValues]]]);Constructor.
Member Functions Inherited From ArgParseArgument
Member Functions Inherited From AssignableConcept
Interface Function Overview
-
void setDefaultValue(option, v);Adds/appends a new value to the list of default values. -
std::string getArgumentLabel(option);Returns the argument label. -
std::string getOptionName(option);Returns the name of the ArgParseOption in a well-formatted way. -
void hideOption(option[, hide]);Hides the ArgParseOption from the help screen (or shows it again). -
bool isAdvanced(option);Return whether an option is only shown in the full help screen. -
bool isFlagOption(option);Returns whether an option is a flag. -
bool isHidden(option);Return whether an option is hidden on the help screen. -
bool isRequired(option);Returns whether the option is mandatory. -
void setAdvanced(option[, advanced]);Shows the ArgParseOption only on the full help screen. -
void setDefaultValue(option, v);Set the default value for the given option. -
void setRequired(option, required);Sets whether or not the option is mandatory. -
void write(stream, option);Writes the basic informationa bout the ArgParseOption to the provided stream.
Interface Functions Inherited From ArgParseArgument
getArgumentLabelgetArgumentTypegetArgumentTypeAsStringgetArgumentValuegetArgumentValuesgetFileExtensionhasArgumentValuehasDefaultisBooleanArgumentisDirectoryArgumentisDoubleArgumentisInputFileArgumentisInputPrefixArgumentisInt64ArgumentisIntegerArgumentisListArgumentisOutputFileArgumentisOutputPrefixArgumentisSetisStringArgumentnumberOfAllowedValuessetHelpTextsetMaxValuesetMinValuesetValidValues
Interface Functions Inherited From AssignableConcept
Detailed Description
You can use the shortcut addOption for adding options to ArgumentParser object.
Member Functions Detail
ArgParseOption::ArgParseOption(shortName, longName, helpText, argumentType[, argumentLabel[, isList[, numValues]]]);
Constructor.
Parameters
shortName
|
The short name of the argument. |
|---|---|
longName
|
The long name of the argument (std::string). |
helpText
|
The text to display as help (std::string). |
argumentType
|
The type of the argument (ArgParseArgument::ArgumentType). |
argumentLabel
|
The label for the value to use in the help display, e.g. 'INT' in '--value INT' (std::string). |
isList
|
Flag for whether this option can be given multiple times (bool, true for allowing multiple values). |
numValues
|
Number of command line arguments that each option should bind (unsigned). |
Short and Long Option Names
Short option names are passed to the program following one dash (e.g. '-i', '-e'). Long optiongs are passed following two dashes (e.g. '--num-threads', '--error-rate'). The leading one or two dashes are not passed to the constructor of ArgParseOption, however.
Naming Conventions
- Keep the short name short, ideally to one character.
- Only use lower-case characters in the long name, use dashes to separate words, only use alphanumeric characters and dashes, no underline characters .
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
Interface Functions Detail
void setDefaultValue(option, v);
Adds/appends a new value to the list of default values.
Parameters
option
|
The ArgParseOption to appen the default value for. |
|---|---|
v
|
The value to append, (any type that can be streamed into an std::stringstream). |
Remarks
This function does not check any length restrictions for this value.
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
std::string getArgumentLabel(option);
Returns the argument label.
Parameters
option
|
The ArgParseOption object to query. |
|---|
Returns
std::string |
The argument label string. |
|---|
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
std::string getOptionName(option);
Returns the name of the ArgParseOption in a well-formatted way.
Parameters
option
|
The ArgParseOption object to query. |
|---|
Returns
std::string |
The option name string. |
|---|
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
void hideOption(option[, hide]);
Hides the ArgParseOption from the help screen (or shows it again).
Parameters
option
|
The ArgParseOption object to set the hidden flag of. |
|---|---|
hide
|
bool that indicates whether to hide the flag (default: true) |
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
bool isAdvanced(option);
Return whether an option is only shown in the full help screen.
Parameters
option
|
The ArgParseOption object to query. |
|---|
Returns
bool |
true if it is hidden, false otherwise. |
|---|
By default, options are not marked as advanced.
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
bool isFlagOption(option);
Returns whether an option is a flag.
Parameters
option
|
The ArgParseOption object to query. |
|---|
Returns
bool |
true if option is a flag/switch and false otherwise. |
|---|
Flags are given without arguments, e.g. the -l flag in the Unix ls command.
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
bool isHidden(option);
Return whether an option is hidden on the help screen.
Parameters
option
|
The ArgParseOption object to query. |
|---|
Returns
bool |
true if it is hidden, false otherwise. |
|---|
By default, options are not hidden.
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
bool isRequired(option);
Returns whether the option is mandatory.
Parameters
option
|
The ArgParseOption object to query. |
|---|
Returns
bool |
true if the option is mandatory and false if it not. |
|---|
By default, options are not mandatory.
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
void setAdvanced(option[, advanced]);
Shows the ArgParseOption only on the full help screen.
Parameters
option
|
The ArgParseOption object to set the advanced flag of. |
|---|---|
advanced
|
bool that indicates whether to hide the flag (default: true) |
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
void setDefaultValue(option, v);
Set the default value for the given option.
Parameters
option
|
The ArgParseOption to set the default value for. |
|---|---|
v
|
The value to set, (any type that can be streamed into an std::stringstream). |
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
void setRequired(option, required);
Sets whether or not the option is mandatory.
Parameters
option
|
The ArgParseOption to modify. |
|---|---|
required
|
Flag whether the option is mandatory (bool). |
By default, options are not mandatory.
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
void write(stream, option);
Writes the basic informationa bout the ArgParseOption to the provided stream.
Parameters
stream
|
The stream to write to. |
|---|---|
option
|
The ArgParseOption object to write to stream. |
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.