robot.utils.argumentparser
¶
ArgumentParser
¶
Available options and tool name are read from the usage.
Tool name is got from the first row of the usage. It is either the whole row or anything before first ' -- '.
Source code in src/robot/utils/argumentparser.py
parse_args
¶
Parse given arguments and return options and positional arguments.
Arguments must be given as a list and are typically sys.argv[1:].
Options are returned as a dictionary where long options are keys. Value is a string for those options that can be given only one time (if they are given multiple times the last value is used) or None if the option is not used at all. Value for options that can be given multiple times (denoted with '*' in the usage) is a list which contains all the given values and is empty if options are not used. Options not taken arguments have value False when they are not set and True otherwise.
Positional arguments are returned as a list in the order they are given.
If 'check_args' is True, this method will automatically check that correct number of arguments, as parsed from the usage line, are given. If the last argument in the usage line ends with the character 's', the maximum number of arguments is infinite.
Possible errors in processing arguments are reported using DataError.
Some options have a special meaning and are handled automatically if defined in the usage and given from the command line:
--argumentfile can be used to automatically read arguments from a specified file. When --argumentfile is used, the parser always allows using it multiple times. Adding '*' to denote that is thus recommend. A special value 'stdin' can be used to read arguments from stdin instead of a file.
--pythonpath can be used to add extra path(s) to sys.path. This functionality was deprecated in Robot Framework 5.0.
--help and --version automatically generate help and version messages.
Version is generated based on the tool name and version -- see init
for information how to set them. Help contains the whole usage given to
init. Possible