A parameter to a command comes in two versions: they are either
Option
s or 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.
Parameters | |
param_decls | the parameter declarations for this option or argument. This is a list of flags or argument names. |
type | the type that should be used. Either a ParamType
or a Python type. The later is converted into the former
automatically if supported. |
required | controls if this is optional or not. |
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. |
callback | A function to further process or validate the value after type conversion. It is called as f(ctx, param, value) and must return the value. It is called for all sources, including prompts. |
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). If nargs=-1, all remaining parameters are collected. |
metavar | how the value is represented in the help page. |
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. |
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. |
envvar | a string or list of strings that are environment variables that should be checked. |
shell_complete | A function that returns custom shell
completions. Used instead of the param's type completion if
given. Takes ctx, param, incomplete and must return a list
of ~click.shell_completion.CompletionItem or a list of
strings. |
Method | __init__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | _parse_decls |
Undocumented |
Method | add_to_parser |
Undocumented |
Method | consume_value |
Undocumented |
Method | get_default |
Get the default for the parameter. Tries Context.lookup_default first, then the local default. |
Method | get_error_hint |
Get a stringified version of the param for use in error messages to indicate which param caused the error. |
Method | get_help_record |
Undocumented |
Method | get_usage_pieces |
Undocumented |
Method | handle_parse_result |
Undocumented |
Method | make_metavar |
Undocumented |
Method | process_value |
Undocumented |
Method | resolve_envvar_value |
Undocumented |
Method | shell_complete |
No summary |
Method | to_info_dict |
Gather information that could be useful for a tool generating user-facing documentation. |
Method | type_cast_value |
Convert and validate a value against the option's type , multiple , and nargs . |
Method | value_from_envvar |
Undocumented |
Method | value_is_missing |
Undocumented |
Class Variable | param_type_name |
Undocumented |
Instance Variable | _custom_shell_complete |
Undocumented |
Instance Variable | callback |
Undocumented |
Instance Variable | default |
Undocumented |
Instance Variable | envvar |
Undocumented |
Instance Variable | expose_value |
Undocumented |
Instance Variable | is_eager |
Undocumented |
Instance Variable | metavar |
Undocumented |
Instance Variable | multiple |
Undocumented |
Instance Variable | name |
Undocumented |
Instance Variable | nargs |
Undocumented |
Instance Variable | opts |
Undocumented |
Instance Variable | required |
Undocumented |
Instance Variable | secondary_opts |
Undocumented |
Instance Variable | type |
Undocumented |
Property | human_readable_name |
Returns the human readable name of this parameter. This is the same as the name for options, but the metavar for arguments. |
click.core.Argument
, click.core.Option
Undocumented
Parameters | |
param_decls:t.Optional[ | Undocumented |
type:t.Optional[ | Undocumented |
required:bool | Undocumented |
default:t.Optional[ | Undocumented |
callback:t.Optional[ | Undocumented |
nargs:t.Optional[ | Undocumented |
multiple:bool | Undocumented |
metavar:t.Optional[ | Undocumented |
expose_value:bool | Undocumented |
is_eager:bool | Undocumented |
envvar:t.Optional[ | Undocumented |
shell_complete:t.Optional[ | Undocumented |
autocompletion:t.Optional[ | Undocumented |
click.core.Argument
, click.core.Option
Undocumented
Parameters | |
decls:t.Sequence[ | Undocumented |
expose_value:bool | Undocumented |
Returns | |
t.Tuple[ | Undocumented |
click.core.Argument
, click.core.Option
Undocumented
Parameters | |
parser:OptionParser | Undocumented |
ctx:Context | Undocumented |
click.core.Option
Undocumented
Parameters | |
ctx:Context | Undocumented |
opts:t.Mapping[ | Undocumented |
Returns | |
t.Tuple[ | Undocumented |
click.core.Option
Get the default for the parameter. Tries
Context.lookup_default
first, then the local default.
Parameters | |
ctx:Context | Current context. |
call:bool | If the default is a callable, call it. Disable to return the callable instead. |
Returns | |
t.Optional[ | Undocumented |
click.core.Argument
Parameters | |
ctx:Context | Undocumented |
Returns | |
str | Undocumented |
click.core.Option
Undocumented
Parameters | |
ctx:Context | Undocumented |
Returns | |
t.Optional[ | Undocumented |
click.core.Argument
Undocumented
Parameters | |
ctx:Context | Undocumented |
Returns | |
t.List[ | Undocumented |
Undocumented
Parameters | |
ctx:Context | Undocumented |
opts:t.Mapping[ | Undocumented |
args:t.List[ | Undocumented |
Returns | |
t.Tuple[ | Undocumented |
Undocumented
Parameters | |
ctx:Context | Undocumented |
value:t.Any | Undocumented |
Returns | |
t.Any | Undocumented |
click.core.Option
Undocumented
Parameters | |
ctx:Context | Undocumented |
Returns | |
t.Optional[ | Undocumented |
Return a list of completions for the incomplete value. If a
shell_complete function was given during init, it is used.
Otherwise, the type
~click.types.ParamType.shell_complete
function is used.
Parameters | |
ctx:Context | Invocation context for this command. |
incomplete:str | Value being completed. May be empty. |
Returns | |
t.List[ | Undocumented |
click.core.Option
Gather information that could be useful for a tool generating user-facing documentation.
Use click.Context.to_info_dict
to traverse the entire
CLI structure.
Returns | |
t.Dict[ | Undocumented |
click.core.Option
Undocumented
Parameters | |
ctx:Context | Undocumented |
Returns | |
t.Optional[ | Undocumented |
Undocumented
Parameters | |
value:t.Any | Undocumented |
Returns | |
bool | Undocumented |
str
=
click.core.Argument