class OptionParser:
The option parser is an internal class that is ultimately used to parse options and arguments. It's modelled after optparse and brings a similar but vastly simplified API. It should generally not be used directly as the high level Click classes wrap it for you.
It's not nearly as extensible as optparse or argparse as it does not implement features that are implemented on a higher level (such as types or defaults).
Parameters | |
ctx | optionally the ~click.Context where this parser
should go with. |
Method | __init__ |
Undocumented |
Method | _get_value_from_state |
Undocumented |
Method | _match_long_opt |
Undocumented |
Method | _match_short_opt |
Undocumented |
Method | _process_args_for_args |
Undocumented |
Method | _process_args_for_options |
Undocumented |
Method | _process_opts |
Undocumented |
Method | add_argument |
Adds a positional argument named dest to the parser. |
Method | add_option |
No summary |
Method | parse_args |
No summary |
Instance Variable | _args |
Undocumented |
Instance Variable | _long_opt |
Undocumented |
Instance Variable | _opt_prefixes |
Undocumented |
Instance Variable | _short_opt |
Undocumented |
Instance Variable | allow_interspersed_args |
Undocumented |
Instance Variable | ctx |
Undocumented |
Instance Variable | ignore_unknown_options |
Undocumented |
Undocumented
Parameters | |
option_name:str | Undocumented |
option:Option | Undocumented |
state:ParsingState | Undocumented |
Returns | |
t.Any | Undocumented |
Undocumented
Parameters | |
opt:str | Undocumented |
explicit_value:t.Optional[ | Undocumented |
state:ParsingState | Undocumented |
Undocumented
Parameters | |
arg:str | Undocumented |
state:ParsingState | Undocumented |
Undocumented
Parameters | |
arg:str | Undocumented |
state:ParsingState | Undocumented |
Adds a positional argument named dest
to the parser.
The obj
can be used to identify the option in the order list
that is returned from the parser.
Parameters | |
obj:CoreArgument | Undocumented |
dest:t.Optional[ | Undocumented |
nargs:int | Undocumented |
Adds a new option named dest
to the parser. The destination
is not inferred (unlike with optparse) and needs to be explicitly
provided. Action can be any of store, store_const,
append, append_const or count.
The obj
can be used to identify the option in the order list
that is returned from the parser.
Parameters | |
obj:CoreOption | Undocumented |
opts:t.Sequence[ | Undocumented |
dest:t.Optional[ | Undocumented |
action:t.Optional[ | Undocumented |
nargs:int | Undocumented |
const:t.Optional[ | Undocumented |
Parameters | |
args:t.List[ | Undocumented |
Returns | |
t.Tuple[ | Undocumented |