Skip to main content

get_command_line_option

Return the value of a command line option (which should include leading dashes, e.g. '--testrunner') from an argument list. Return None if the option wasn't passed or if the argument list couldn't be parsed.

def get_command_line_option(
argv: list,
option: string
) - > string

Return the value of a command line option (which should include leading dashes, e.g. '--testrunner') from an argument list. Return None if the option wasn't passed or if the argument list couldn't be parsed.

Parameters

NameTypeDescription
argvlistThe list of command line arguments to search, typically starting from the third element to skip the executable and subcommand
optionstringThe specific flag name to retrieve, including leading dashes (e.g., '--settings')

Returns

TypeDescription
stringThe value associated with the specified command line option, or None if the option is missing or parsing fails