set_type()
Rationale
This method allows you to set the type of type of the argument that has to be parsed from the command line arguments.
It is used to parse differently based on the type of the argument. For example, boolean arguments do not expect after their name any kind of value, whereas string or int arguments do.
List of supported argument types
It is worth be aware of that if you do not call set_type(), on a Arg instance, the type of the argument will default to argparse::ArgTypes::STRING.
enum class ArgTypes
{
STRING = 0,
INT,
BOOL
};
Example usage
parser.add_argument("--string", "-S").set_type(argparse::ArgTypes::STRING);
parser.add_argument("--int", "-I").set_type(argparse::ArgTypes::INT);
parser.add_argument("--bool", "-B").set_type(argparse::ArgTypes::BOOL);
Source Code
Arg &set_type(const ArgTypes &type)
{
this->type = type;
return *this;
}