|
def | __init__ (self, param_decls=None, type=None, required=False, default=None, callback=None, nargs=None, metavar=None, expose_value=True, is_eager=False, envvar=None, autocompletion=None) |
|
def | __repr__ (self) |
|
def | human_readable_name (self) |
|
def | make_metavar (self) |
|
def | get_default (self, ctx) |
|
def | add_to_parser (self, parser, ctx) |
|
def | consume_value (self, ctx, opts) |
|
def | type_cast_value (self, ctx, value) |
|
def | process_value (self, ctx, value) |
|
def | value_is_missing (self, value) |
|
def | full_process_value (self, ctx, value) |
|
def | resolve_envvar_value (self, ctx) |
|
def | value_from_envvar (self, ctx) |
|
def | handle_parse_result (self, ctx, opts, args) |
|
def | get_help_record (self, ctx) |
|
def | get_usage_pieces (self, ctx) |
|
def | get_error_hint (self, ctx) |
|
A parameter to a command comes in two versions: they are either
:class:`Option`\s or :class:`Argument`\s. Other subclasses are currently
not supported by design as some of the internals for parsing are
intentionally not finalized.
Some settings are supported by both options and arguments.
:param param_decls: the parameter declarations for this option or
argument. This is a list of flags or argument
names.
:param type: the type that should be used. Either a :class:`ParamType`
or a Python type. The later is converted into the former
automatically if supported.
:param required: controls if this is optional or not.
:param default: the default value if omitted. This can also be a callable,
in which case it's invoked when the default is needed
without any arguments.
:param callback: a callback that should be executed after the parameter
was matched. This is called as ``fn(ctx, param,
value)`` and needs to return the value.
:param nargs: the number of arguments to match. If not ``1`` the return
value is a tuple instead of single value. The default for
nargs is ``1`` (except if the type is a tuple, then it's
the arity of the tuple).
:param metavar: how the value is represented in the help page.
:param expose_value: if this is `True` then the value is passed onwards
to the command callback and stored on the context,
otherwise it's skipped.
:param is_eager: eager values are processed before non eager ones. This
should not be set for arguments or it will inverse the
order of processing.
:param envvar: a string or list of strings that are environment variables
that should be checked.
.. versionchanged:: 7.1
Empty environment variables are ignored rather than taking the
empty string value. This makes it possible for scripts to clear
variables if they can't unset them.
.. versionchanged:: 2.0
Changed signature for parameter callback to also be passed the
parameter. The old callback format will still work, but it will
raise a warning to give you a chance to migrate the code easier.