summaryrefslogtreecommitdiff
path: root/docs/shell-completion.rst
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2020-10-03 09:23:39 -0700
committerDavid Lord <davidism@gmail.com>2020-10-03 12:28:50 -0700
commit3faede8b430ef88f36d3efa513f5e4065a3f3a7e (patch)
tree65e9b97026dede78c77990e750f54a2d4dbc7a68 /docs/shell-completion.rst
parentcb5c21ee379ff33318dc32cda5483ed516b918f2 (diff)
downloadclick-3faede8b430ef88f36d3efa513f5e4065a3f3a7e.tar.gz
rename autocompletion to shell_complete
new function takes additional param arg, must return a homogeneous list of strings or CompletionItem, and must perform matching on results
Diffstat (limited to 'docs/shell-completion.rst')
-rw-r--r--docs/shell-completion.rst7
1 files changed, 4 insertions, 3 deletions
diff --git a/docs/shell-completion.rst b/docs/shell-completion.rst
index 739a7c7..a02c3be 100644
--- a/docs/shell-completion.rst
+++ b/docs/shell-completion.rst
@@ -148,11 +148,12 @@ Overriding Value Completion
---------------------------
Value completions for a parameter can be customized without a custom
-type by providing an ``autocompletion`` function. The function is used
+type by providing a ``shell_complete`` function. The function is used
instead of any completion provided by the type. It is passed 3 keyword
arguments:
- ``ctx`` - The current command context.
+- ``param`` - The current parameter requesting completion.
- ``args`` - The list of complete args before the incomplete value.
- ``incomplete`` - The partial word that is being completed. May
be an empty string if no characters have been entered yet.
@@ -165,11 +166,11 @@ start with the incomplete value.
.. code-block:: python
- def complete_env_vars(ctx, args, incomplete):
+ def complete_env_vars(ctx, param, args, incomplete):
return [k for k in os.environ if k.startswith(incomplete)]
@click.command()
- @click.argument("name", autocompletion=complete_env_vars)
+ @click.argument("name", shell_complete=complete_env_vars)
def cli(name):
click.echo(f"Name: {name}")
click.echo(f"Value: {os.environ[name]}")