Reference
Option
Option(
name: Optional[str] = None,
flags: Optional[List[str]] = None,
description: Optional[str] = None,
required: Optional[bool] = False,
action: Optional[
Literal[
"store",
"store_true",
"store_false",
"append",
"extend",
"count",
]
] = "store",
default: Optional[str] = None,
choices: Optional[List[Any]] = None,
type: Optional[type] = str,
nargs: Optional[Union[int, Literal["*"]]] = None,
)
Parameters:
-
(nameOptional[str], default:None) –This is the name of the option. The resolved value should be referenced by this name in the handler. If not provided, the flag name will be used. If both the short and long flags are provided, the long flag name will be used.
-
(flagsOptional[List[str], default:None) –The flags to use for the option. At most 1 short flag and 1 long flag are allowed. If not provided, the name parameter will be used as the long flag.
-
(descriptionOptional[str], default:None) –The description to display for the option.
-
(requiredOptional[bool], default:False) –Whether the option is required.
-
(actionOptional[Literal['store', 'store_true', 'store_false', 'append', 'extend', 'count']], default:'store') –The action to take with the option. Default is "store".
-
(defaultOptional[str], default:None) –The default value for the option.
-
(choicesOptional[List[Any]], default:None) –The choices available for the option.
-
(typeOptional[type], default:str) –The type of the option.
-
(nargsOptional[Union[int, Literal['*']]], default:None) –The number of arguments that should be consumed. This is only applicable for actions - "store", "append", and "extend". if nargs is not None, the resolved value for the Option will be always be a list.
Methods:
-
handle–Handle the value of the option based on Option setup.
-
parse–Parse the raw value from the command line.
-
validate–Validate the value of the option.
Attributes:
-
action– -
choices– -
default– -
description– -
flags– -
long_name(str) – -
name– -
nargs– -
required– -
short_name(str) – -
type–