|
|
None | __init__ (self, str|None name, cabc.MutableMapping[str, t.Any]|None context_settings=None, t.Callable[..., t.Any]|None callback=None, list[Parameter]|None params=None, str|None help=None, str|None epilog=None, str|None short_help=None, str|None options_metavar="[OPTIONS]", bool add_help_option=True, bool no_args_is_help=False, bool hidden=False, bool|str deprecated=False) |
| |
|
dict[str, t.Any] | to_info_dict (self, Context ctx) |
| |
|
str | __repr__ (self) |
| |
| str | get_usage (self, Context ctx) |
| |
|
list[Parameter] | get_params (self, Context ctx) |
| |
| None | format_usage (self, Context ctx, HelpFormatter formatter) |
| |
| list[str] | collect_usage_pieces (self, Context ctx) |
| |
| list[str] | get_help_option_names (self, Context ctx) |
| |
| Option|None | get_help_option (self, Context ctx) |
| |
| _OptionParser | make_parser (self, Context ctx) |
| |
| str | get_help (self, Context ctx) |
| |
| str | get_short_help_str (self, int limit=45) |
| |
| None | format_help (self, Context ctx, HelpFormatter formatter) |
| |
| None | format_help_text (self, Context ctx, HelpFormatter formatter) |
| |
| None | format_options (self, Context ctx, HelpFormatter formatter) |
| |
| None | format_epilog (self, Context ctx, HelpFormatter formatter) |
| |
| Context | make_context (self, str|None info_name, list[str] args, Context|None parent=None, **t.Any extra) |
| |
|
list[str] | parse_args (self, Context ctx, list[str] args) |
| |
| t.Any | invoke (self, Context ctx) |
| |
| list[CompletionItem] | shell_complete (self, Context ctx, str incomplete) |
| |
|
t.NoReturn | main (self, cabc.Sequence[str]|None args=None, str|None prog_name=None, str|None complete_var=None, t.Literal[True] standalone_mode=True, **t.Any extra) |
| |
|
t.Any | main (self, cabc.Sequence[str]|None args=None, str|None prog_name=None, str|None complete_var=None, bool standalone_mode=..., **t.Any extra) |
| |
| t.Any | main (self, cabc.Sequence[str]|None args=None, str|None prog_name=None, str|None complete_var=None, bool standalone_mode=True, bool windows_expand_args=True, **t.Any extra) |
| |
| t.Any | __call__ (self, *t.Any args, **t.Any kwargs) |
| |
Commands are the basic building block of command line interfaces in
Click. A basic command handles command line parsing and might dispatch
more parsing to commands nested below it.
:param name: the name of the command to use unless a group overrides it.
:param context_settings: an optional dictionary with defaults that are
passed to the context object.
:param callback: the callback to invoke. This is optional.
:param params: the parameters to register with this command. This can
be either :class:`Option` or :class:`Argument` objects.
:param help: the help string to use for this command.
:param epilog: like the help string but it's printed at the end of the
help page after everything else.
:param short_help: the short help to use for this command. This is
shown on the command listing of the parent command.
:param add_help_option: by default each command registers a ``--help``
option. This can be disabled by this parameter.
:param no_args_is_help: this controls what happens if no arguments are
provided. This option is disabled by default.
If enabled this will add ``--help`` as argument
if no arguments are passed
:param hidden: hide this command from help outputs.
:param deprecated: If ``True`` or non-empty string, issues a message
indicating that the command is deprecated and highlights
its deprecation in --help. The message can be customized
by using a string as the value.
.. versionchanged:: 8.2
This is the base class for all commands, not ``BaseCommand``.
``deprecated`` can be set to a string as well to customize the
deprecation message.
.. versionchanged:: 8.1
``help``, ``epilog``, and ``short_help`` are stored unprocessed,
all formatting is done when outputting help text, not at init,
and is done even if not using the ``@command`` decorator.
.. versionchanged:: 8.0
Added a ``repr`` showing the command name.
.. versionchanged:: 7.1
Added the ``no_args_is_help`` parameter.
.. versionchanged:: 2.0
Added the ``context_settings`` parameter.
| t.Any click.core.Command.main |
( |
|
self, |
|
|
cabc.Sequence[str] | None |
args = None, |
|
|
str | None |
prog_name = None, |
|
|
str | None |
complete_var = None, |
|
|
bool |
standalone_mode = True, |
|
|
bool |
windows_expand_args = True, |
|
|
**t.Any |
extra |
|
) |
| |
This is the way to invoke a script with all the bells and
whistles as a command line application. This will always terminate
the application after a call. If this is not wanted, ``SystemExit``
needs to be caught.
This method is also available by directly calling the instance of
a :class:`Command`.
:param args: the arguments that should be used for parsing. If not
provided, ``sys.argv[1:]`` is used.
:param prog_name: the program name that should be used. By default
the program name is constructed by taking the file
name from ``sys.argv[0]``.
:param complete_var: the environment variable that controls the
bash completion support. The default is
``"_<prog_name>_COMPLETE"`` with prog_name in
uppercase.
:param standalone_mode: the default behavior is to invoke the script
in standalone mode. Click will then
handle exceptions and convert them into
error messages and the function will never
return but shut down the interpreter. If
this is set to `False` they will be
propagated to the caller and the return
value of this function is the return value
of :meth:`invoke`.
:param windows_expand_args: Expand glob patterns, user dir, and
env vars in command line args on Windows.
:param extra: extra keyword arguments are forwarded to the context
constructor. See :class:`Context` for more information.
.. versionchanged:: 8.0.1
Added the ``windows_expand_args`` parameter to allow
disabling command line arg expansion on Windows.
.. versionchanged:: 8.0
When taking arguments from ``sys.argv`` on Windows, glob
patterns, user dir, and env vars are expanded.
.. versionchanged:: 3.0
Added the ``standalone_mode`` parameter.