class documentation

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: issues a message indicating that the command is deprecated. .. 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.

Method __init__ Undocumented
Method collect_usage_pieces Returns all the pieces that go into the usage line and returns it as a list of strings.
Method format_epilog Writes the epilog into the formatter if it exists.
Method format_help Writes the help into the formatter if it exists.
Method format_help_text Writes the help text to the formatter if it exists.
Method format_options Writes all the options into the formatter if they exist.
Method format_usage Writes the usage line into the formatter.
Method get_help Formats the help into a string and returns it.
Method get_help_option Returns the help option object.
Method get_help_option_names Returns the names for the help option.
Method get_params Undocumented
Method get_short_help_str Gets short help for the command or makes it by shortening the long help string.
Method get_usage Formats the usage line into a string and returns it.
Method invoke Given a context, this invokes the attached callback (if it exists) in the right way.
Method make_parser Creates the underlying option parser for this command.
Method parse_args Given a context and a list of arguments this creates the parser and parses the arguments, then modifies the context as necessary. This is automatically invoked by :meth:`make_context`.
Method shell_complete Return a list of completions for the incomplete value. Looks at the names of options and chained multi-commands.
Method to_info_dict Gather information that could be useful for a tool generating user-facing documentation. This traverses the entire structure below this command.
Instance Variable add_help_option Undocumented
Instance Variable callback Undocumented
Instance Variable deprecated Undocumented
Instance Variable epilog Undocumented
Instance Variable help Undocumented
Instance Variable hidden Undocumented
Instance Variable no_args_is_help Undocumented
Instance Variable options_metavar Undocumented
Instance Variable params Undocumented
Instance Variable short_help Undocumented

Inherited from BaseCommand:

Method __call__ Alias for :meth:`main`.
Method __repr__ Undocumented
Method main 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.
Method make_context This function when given an info name and arguments will kick off the parsing and create a new :class:`Context`. It does not invoke the actual command callback though.
Class Variable allow_extra_args Undocumented
Class Variable allow_interspersed_args Undocumented
Class Variable ignore_unknown_options Undocumented
Instance Variable context_settings Undocumented
Instance Variable name Undocumented
Method _main_shell_completion Check if the shell is asking for tab completion, process that, then exit early. Called from :meth:`main` before the program is invoked.
def __init__(self, name, context_settings=None, callback=None, params=None, help=None, epilog=None, short_help=None, options_metavar='[OPTIONS]', add_help_option=True, no_args_is_help=False, hidden=False, deprecated=False): (source)

Undocumented

Parameters
name:t.Optional[str]Undocumented
context_settings:t.Optional[t.Dict[str, t.Any]]Undocumented
callback:t.Optional[t.Callable[..., t.Any]]Undocumented
params:t.Optional[t.List[Parameter]]Undocumented
help:t.Optional[str]Undocumented
epilog:t.Optional[str]Undocumented
short_help:t.Optional[str]Undocumented
options_metavar:t.Optional[str]Undocumented
add_help_option:boolUndocumented
no_args_is_help:boolUndocumented
hidden:boolUndocumented
deprecated:boolUndocumented
def collect_usage_pieces(self, ctx): (source)

Returns all the pieces that go into the usage line and returns it as a list of strings.

Parameters
ctx:ContextUndocumented
Returns
t.List[str]Undocumented
def format_epilog(self, ctx, formatter): (source)

Writes the epilog into the formatter if it exists.

Parameters
ctx:ContextUndocumented
formatter:HelpFormatterUndocumented
def format_help(self, ctx, formatter): (source)

Writes the help into the formatter if it exists. This is a low-level method called by :meth:`get_help`. This calls the following methods: - :meth:`format_usage` - :meth:`format_help_text` - :meth:`format_options` - :meth:`format_epilog`

Parameters
ctx:ContextUndocumented
formatter:HelpFormatterUndocumented
def format_help_text(self, ctx, formatter): (source)

Writes the help text to the formatter if it exists.

Parameters
ctx:ContextUndocumented
formatter:HelpFormatterUndocumented
def format_options(self, ctx, formatter): (source)

Writes all the options into the formatter if they exist.

Parameters
ctx:ContextUndocumented
formatter:HelpFormatterUndocumented
def format_usage(self, ctx, formatter): (source)

Writes the usage line into the formatter. This is a low-level method called by :meth:`get_usage`.

Parameters
ctx:ContextUndocumented
formatter:HelpFormatterUndocumented
def get_help(self, ctx): (source)

Formats the help into a string and returns it. Calls :meth:`format_help` internally.

Parameters
ctx:ContextUndocumented
Returns
strUndocumented
def get_help_option(self, ctx): (source)

Returns the help option object.

Parameters
ctx:ContextUndocumented
Returns
t.Optional[Option]Undocumented
def get_help_option_names(self, ctx): (source)

Returns the names for the help option.

Parameters
ctx:ContextUndocumented
Returns
t.List[str]Undocumented
def get_params(self, ctx): (source)

Undocumented

Parameters
ctx:ContextUndocumented
Returns
t.List[Parameter]Undocumented
def get_short_help_str(self, limit=45): (source)

Gets short help for the command or makes it by shortening the long help string.

Parameters
limit:intUndocumented
Returns
strUndocumented
def get_usage(self, ctx): (source)

Formats the usage line into a string and returns it. Calls :meth:`format_usage` internally.

Parameters
ctx:ContextUndocumented
Returns
strUndocumented
def invoke(self, ctx): (source)

Given a context, this invokes the attached callback (if it exists) in the right way.

Parameters
ctx:ContextUndocumented
Returns
t.AnyUndocumented
def make_parser(self, ctx): (source)

Creates the underlying option parser for this command.

Parameters
ctx:ContextUndocumented
Returns
OptionParserUndocumented
def parse_args(self, ctx, args): (source)

Given a context and a list of arguments this creates the parser and parses the arguments, then modifies the context as necessary. This is automatically invoked by :meth:`make_context`.

Parameters
ctx:ContextUndocumented
args:t.List[str]Undocumented
Returns
t.List[str]Undocumented
def shell_complete(self, ctx, incomplete): (source)

Return a list of completions for the incomplete value. Looks at the names of options and chained multi-commands. :param ctx: Invocation context for this command. :param incomplete: Value being completed. May be empty. .. versionadded:: 8.0

Parameters
ctx:ContextUndocumented
incomplete:strUndocumented
Returns
t.List[CompletionItem]Undocumented
def to_info_dict(self, ctx): (source)

Gather information that could be useful for a tool generating user-facing documentation. This traverses the entire structure below this command. Use :meth:`click.Context.to_info_dict` to traverse the entire CLI structure. :param ctx: A :class:`Context` representing this command. .. versionadded:: 8.0

Parameters
ctx:ContextUndocumented
Returns
t.Dict[str, t.Any]Undocumented
add_help_option = (source)

Undocumented

callback = (source)

Undocumented

deprecated = (source)

Undocumented

epilog = (source)

Undocumented

help = (source)

Undocumented

hidden = (source)

Undocumented

no_args_is_help = (source)

Undocumented

options_metavar = (source)

Undocumented

Undocumented

short_help = (source)

Undocumented