module documentation

Undocumented

Class ​Completion​Item No summary
Class ​Shell​Complete 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).
Function add​_completion​_class Register a ShellComplete subclass under the given name. The name will be provided by the completion instruction environment variable during completion.
Class ​Bash​Complete Shell completion for Bash.
Class ​Fish​Complete Shell completion for Fish.
Class ​Zsh​Complete Shell completion for Zsh.
Function ​_is​_incomplete​_argument Determine if the given parameter is an argument that can still accept values.
Function ​_is​_incomplete​_option Determine if the given parameter is an option that needs a value.
Function ​_resolve​_context Produce the context hierarchy starting with the command and traversing the complete arguments. This only follows the commands, it doesn't trigger input prompts or callbacks.
Function ​_resolve​_incomplete Find the Click object that will handle the completion of the incomplete value. Return the object and the incomplete value.
Function ​_start​_of​_option Check if the value looks like the start of an option.
Function get​_completion​_class Look up a registered ShellComplete subclass by the name provided by the completion instruction environment variable. If the name isn't registered, returns None.
Function shell​_complete Perform shell completion for the given CLI program.
Constant ​_SOURCE​_BASH Undocumented
Constant ​_SOURCE​_FISH Undocumented
Constant ​_SOURCE​_ZSH Undocumented
Variable ​_available​_shells Undocumented
def add_completion_class(cls, name=None):
Register a ShellComplete subclass under the given name. The name will be provided by the completion instruction environment variable during completion.
Parameters
cls:t.Type[ShellComplete]The completion class that will handle completion for the shell.
name:t.Optional[str]Name to register the class under. Defaults to the class's name attribute.
def _is_incomplete_argument(ctx, param):
Determine if the given parameter is an argument that can still accept values.
Parameters
ctx:ContextInvocation context for the command represented by the parsed complete args.
param:ParameterArgument object being checked.
Returns
boolUndocumented
def _is_incomplete_option(args, param):
Determine if the given parameter is an option that needs a value.
Parameters
args:t.List[str]List of complete args before the incomplete value.
param:ParameterOption object being checked.
Returns
boolUndocumented
def _resolve_context(cli, ctx_args, prog_name, args):
Produce the context hierarchy starting with the command and traversing the complete arguments. This only follows the commands, it doesn't trigger input prompts or callbacks.
Parameters
cli:BaseCommandCommand being called.
ctx​_args:t.Dict[str, t.Any]Undocumented
prog​_name:strName of the executable in the shell.
args:t.List[str]List of complete args before the incomplete value.
Returns
ContextUndocumented
def _resolve_incomplete(ctx, args, incomplete):
Find the Click object that will handle the completion of the incomplete value. Return the object and the incomplete value.
Parameters
ctx:ContextInvocation context for the command represented by the parsed complete args.
args:t.List[str]List of complete args before the incomplete value.
incomplete:strValue being completed. May be empty.
Returns
t.Tuple[t.Union[BaseCommand, Parameter], str]Undocumented
def _start_of_option(value):
Check if the value looks like the start of an option.
Parameters
value:strUndocumented
Returns
boolUndocumented
def get_completion_class(shell):
Look up a registered ShellComplete subclass by the name provided by the completion instruction environment variable. If the name isn't registered, returns None.
Parameters
shell:strName the class is registered under.
Returns
t.Optional[t.Type[ShellComplete]]Undocumented
def shell_complete(cli, ctx_args, prog_name, complete_var, instruction):
Perform shell completion for the given CLI program.
Parameters
cli:BaseCommandCommand being called.
ctx​_args:t.Dict[str, t.Any]Extra arguments to pass to cli.make_context.
prog​_name:strName of the executable in the shell.
complete​_var:strName of the environment variable that holds the completion instruction.
instruction:strValue of complete_var with the completion instruction and shell, in the form instruction_shell.
Returns
intStatus code to exit with.
_SOURCE_BASH: str =

Undocumented

Value
'''%(complete_func)s() {
    local IFS=$\'\\n\'
    local response

    response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD %(comple
te_var)s=bash_complete $1)

...
_SOURCE_FISH: str =

Undocumented

Value
'''function %(complete_func)s;
    set -l response;

    for value in (env %(complete_var)s=fish_complete COMP_WORDS=(commandline -cp
) COMP_CWORD=(commandline -t) %(prog_name)s);
        set response $response $value;
    end;
...
_SOURCE_ZSH: str =

Undocumented

Value
'''#compdef %(prog_name)s

%(complete_func)s() {
    local -a completions
    local -a completions_with_descriptions
    local -a response
    (( ! $+commands[%(prog_name)s] )) && return 1
...
_available_shells: t.Dict[str, t.Type[ShellComplete]] =

Undocumented