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 isBooleanOption(option);
Returns whether an option is a switch. -
bool isHidden(option);
Return whether an option is hidden on the help screen. -
bool isRequired(option);
Returns whether the option is mandatory. -
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
getArgumentLabel
getArgumentValue
getArgumentValues
getFileExtension
hasArgumentValue
hasDefault
isDoubleArgument
isInputFileArgument
isInputPrefixArgument
isInt64Argument
isIntegerArgument
isListArgument
isOutputFileArgument
isOutputPrefixArgument
isSet
isStringArgument
numberOfAllowedValues
setHelpText
setMaxValue
setMinValue
setValidValues
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 .
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.
std::string getArgumentLabel(option);
Returns the argument label.
Parameters
option
|
The ArgParseOption object to query. |
---|
Returns
std::string |
The argument label string. |
---|
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. |
---|
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) |
bool isBooleanOption(option);
Returns whether an option is a switch.
Parameters
option
|
The ArgParseOption object to query. |
---|
Returns
bool |
true if option is a switch and false otherwise. |
---|
Flags are given without arguments, e.g. the -l flag in the Unix ls command.
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.
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.
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). |
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.
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. |