argparse Module
Overview
Members
-
namespace argparse
test DOCUMENTING THE NAMESPACE
Functions
-
bool checkOption(string name, int argc, char *argv[])
Parses through arguments and checks if an option/flag exists.
- Parameters:
name –
stringto match option withargc –
intrepresenting the number of argumentsargv – array of
chararrays, representing string arguments
- Returns:
boolrepresenting whether the flag exists.
-
string getStringArg(string name, int argc, char *argv[], string usage = "")
Gets the value of an argument option as a
stringParses through arguments, and returns value of matching name of the format:
<option> <value>
Where <option> is matched to
name. This functions exits when the option isn’t found, and prints an optional usage message- Parameters:
name –
stringto match option withargc –
intindicating the number of argumentsargv – array of
chararrays, representing string argumentsusage –
stringrepresenting an optional usage message, printed upon failure, default=""
- Returns:
string
-
int getIntArg(string name, int argc, char *argv[], string usage = "")
Gets the value of an argument option as an
intParses through arguments, and returns value of matching name of the format:
<option> <value>
Where <option> is matched to
name. This functions exits when the option isn’t found, and prints an optional usage message- Parameters:
name –
stringto match option withargc –
intindicating the number of argumentsargv – array of
chararrays, representing string argumentsusage –
stringrepresenting an optional usage message, printed upon failure, default=""
- Returns:
int
-
float getFloatArg(string name, int argc, char *argv[], string usage = "")
Gets the value of an argument option as an
floatParses through arguments, and returns value of matching name of the format:
<option> <value>
Where <option> is matched to
name. This functions exits when the option isn’t found, and prints an optional usage message- Parameters:
name –
stringto match option withargc –
intindicating the number of argumentsargv – array of
chararrays, representing string argumentsusage –
stringrepresenting an optional usage message, printed upon failure, default=""
- Returns:
float
-
string getStringArgSecure(string name, string defaultValue, int argc, char *argv[])
Gets the value of an argument option as a
stringParses through arguments, and returns value of matching name of the format:
<option> <value>
Where <option> is matched to
name.- Parameters:
name –
stringto match option withdefaultValue –
stringrepresenting the default value if the option isn’t foundargc –
intindicating the number of argumentsargv – array of
chararrays, representing string arguments
- Returns:
string; will returndefaultValueif the option isn’t found
-
int getIntArgSecure(string name, int defaultValue, int argc, char *argv[])
Gets the value of an argument option as a
intParses through arguments, and returns value of matching name of the format:
<option> <value>
Where <option> is matched to
name.- Parameters:
name –
stringto match option withdefaultValue –
intrepresenting the default value if the option isn’t foundargc –
intindicating the number of argumentsargv – array of
chararrays, representing string arguments
- Returns:
int; will returndefaultValueif the option isn’t found
-
float getFloatArgSecure(string name, float defaultValue, int argc, char *argv[])
Gets the value of an argument option as a
floatParses through arguments, and returns value of matching name of the format:
<option> <value>
Where <option> is matched to
name.- Parameters:
name –
stringto match option withdefaultValue –
floatrepresenting the default value if the option isn’t foundargc –
intindicating the number of argumentsargv – array of
chararrays, representing string arguments
- Returns:
float; will returndefaultValueif the option isn’t found
-
bool checkOption(string name, int argc, char *argv[])