class documentation

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_completion Format a completion item into the form recognized by the shell script. This must be implemented by subclasses.
Method get_completion_args Use the env vars defined by the shell script to return a tuple of ``args, incomplete``. This must be implemented by subclasses.
Method get_completions 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 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_template Completion script template formatted by :meth:`source`. This must be provided by subclasses.
Instance Variable cli Undocumented
Instance Variable complete_var Undocumented
Instance Variable ctx_args Undocumented
Instance Variable prog_name Undocumented
Property func_name The name of the shell function defined by the completion script.
def __init__(self, cli, ctx_args, prog_name, complete_var): (source)

Undocumented

Parameters
cli:BaseCommandUndocumented
ctx_args:t.Dict[str, t.Any]Undocumented
prog_name:strUndocumented
complete_var:strUndocumented
def complete(self): (source)

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
strUndocumented
def format_completion(self, item): (source)

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:CompletionItemUndocumented
Returns
strUndocumented
def get_completion_args(self): (source)

Use the env vars defined by the shell script to return a tuple of ``args, incomplete``. This must be implemented by subclasses.

Returns
t.Tuple[t.List[str], str]Undocumented
def get_completions(self, args, incomplete): (source)

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[str]Undocumented
incomplete:strUndocumented
Returns
t.List[CompletionItem]Undocumented
def source(self): (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`.

Returns
strUndocumented
def source_vars(self): (source)

Vars for formatting :attr:`source_template`. By default this provides ``complete_func``, ``complete_var``, and ``prog_name``.

Returns
t.Dict[str, t.Any]Undocumented

Name to register the shell as with :func:`add_completion_class`. This is used in completion instructions (``{name}_source`` and ``{name}_complete``).

source_template: t.ClassVar[str] = (source)

Completion script template formatted by :meth:`source`. This must be provided by subclasses.

Undocumented

complete_var = (source)

Undocumented

ctx_args = (source)

Undocumented

prog_name = (source)

Undocumented

@property
func_name: str = (source)

The name of the shell function defined by the completion script.