class ShellComplete: (source)
Known subclasses: click.shell_completion.BashComplete
, click.shell_completion.FishComplete
, click.shell_completion.ZshComplete
Base class for providing shell completion support. A subclass for a given shell will override attributes and methods to implement the completion instructions (``source`` and ``complete``). :param cli: Command being called. :param prog_name: Name of the executable in the shell. :param complete_var: Name of the environment variable that holds the completion instruction. .. versionadded:: 8.0
Method | __init__ |
Undocumented |
Method | complete |
Produce the completion data to send back to the shell. |
Method | format |
Format a completion item into the form recognized by the shell script. This must be implemented by subclasses. |
Method | get |
Use the env vars defined by the shell script to return a tuple of ``args, incomplete``. This must be implemented by subclasses. |
Method | get |
Determine the context and last complete command or parameter from the complete args. Call that object's ``shell_complete`` method to get the completions for the incomplete value. |
Method | source |
Produce the shell script that defines the completion function. By default this ``%``-style formats :attr:`source_template` with the dict returned by :meth:`source_vars`. |
Method | source |
Vars for formatting :attr:`source_template`. |
Class Variable | name |
Name to register the shell as with :func:`add_completion_class`. This is used in completion instructions (``{name}_source`` and ``{name}_complete``). |
Class Variable | source |
Completion script template formatted by :meth:`source`. This must be provided by subclasses. |
Instance Variable | cli |
Undocumented |
Instance Variable | complete |
Undocumented |
Instance Variable | ctx |
Undocumented |
Instance Variable | prog |
Undocumented |
Property | func |
The name of the shell function defined by the completion script. |
Produce the completion data to send back to the shell. By default this calls :meth:`get_completion_args`, gets the completions, then calls :meth:`format_completion` for each completion.
Returns | |
str | Undocumented |
click.shell_completion.BashComplete
, click.shell_completion.FishComplete
, click.shell_completion.ZshComplete
Format a completion item into the form recognized by the shell script. This must be implemented by subclasses. :param item: Completion item to format.
Parameters | |
item:CompletionItem | Undocumented |
Returns | |
str | Undocumented |
Determine the context and last complete command or parameter from the complete args. Call that object's ``shell_complete`` method to get the completions for the incomplete value. :param args: List of complete args before the incomplete value. :param incomplete: Value being completed. May be empty.
Parameters | |
args:t.List[ | Undocumented |
incomplete:str | Undocumented |
Returns | |
t.List[ | Undocumented |
click.shell_completion.BashComplete
Produce the shell script that defines the completion function. By default this ``%``-style formats :attr:`source_template` with the dict returned by :meth:`source_vars`.
Returns | |
str | Undocumented |
click.shell_completion.BashComplete
, click.shell_completion.FishComplete
, click.shell_completion.ZshComplete
Name to register the shell as with :func:`add_completion_class`. This is used in completion instructions (``{name}_source`` and ``{name}_complete``).