class documentation

class ShellComplete:

Known subclasses: click.shell_completion.BashComplete, click.shell_completion.FishComplete, click.shell_completion.ZshComplete

View In Hierarchy

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).

New in version 8.0.
Parameters
cliCommand being called.
prog​_nameName of the executable in the shell.
complete​_varName of the environment variable that holds the completion instruction.
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 No summary
Method source​_vars Vars for formatting source_template.
Class Variable name Name to register the shell as with add_completion_class. This is used in completion instructions ({name}_source and {name}_complete).
Class Variable source​_template Completion script template formatted by source. This must be provided by subclasses.
Property func​_name The name of the shell function defined by the completion script.
Method __init__ Undocumented
Instance Variable cli Undocumented
Instance Variable complete​_var Undocumented
Instance Variable ctx​_args Undocumented
Instance Variable prog​_name Undocumented
def complete(self):

Produce the completion data to send back to the shell.

By default this calls get_completion_args, gets the completions, then calls format_completion for each completion.

Returns
strUndocumented
def format_completion(self, item):
Format a completion item into the form recognized by the shell script. This must be implemented by subclasses.
Parameters
item:CompletionItemCompletion item to format.
Returns
strUndocumented
def get_completion_args(self):
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):
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.
Parameters
args:t.List[str]List of complete args before the incomplete value.
incomplete:strValue being completed. May be empty.
Returns
t.List[CompletionItem]Undocumented
def source(self):
Produce the shell script that defines the completion function. By default this %-style formats source_template with the dict returned by source_vars.
Returns
strUndocumented
def source_vars(self):

Vars for formatting source_template.

By default this provides complete_func, complete_var, and prog_name.

Returns
t.Dict[str, t.Any]Undocumented
name: t.ClassVar[str] =
Name to register the shell as with add_completion_class. This is used in completion instructions ({name}_source and {name}_complete).
source_template: t.ClassVar[str] =
Completion script template formatted by source. This must be provided by subclasses.
@property
func_name: str =
The name of the shell function defined by the completion script.
def __init__(self, cli, ctx_args, prog_name, complete_var):

Undocumented

Parameters
cli:BaseCommandUndocumented
ctx​_args:t.Dict[str, t.Any]Undocumented
prog​_name:strUndocumented
complete​_var:strUndocumented
cli =

Undocumented

complete_var =

Undocumented

ctx_args =

Undocumented

prog_name =

Undocumented