From 48cb86d85fc1abfcf1478ee660e42aaa5382fd64 Mon Sep 17 00:00:00 2001 From: David Lord Date: Thu, 27 May 2021 07:31:01 -0700 Subject: fix completion example --- examples/completion/README | 6 +++--- examples/completion/completion.py | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/completion/README b/examples/completion/README index f15654e..372b1d4 100644 --- a/examples/completion/README +++ b/examples/completion/README @@ -11,18 +11,18 @@ For Bash: .. code-block:: bash - eval "$(_COMPLETION_COMPLETE=source_bash completion)" + eval "$(_COMPLETION_COMPLETE=bash_source completion)" For Zsh: .. code-block:: zsh - eval "$(_COMPLETION_COMPLETE=source_zsh completion)" + eval "$(_COMPLETION_COMPLETE=zsh_source completion)" For Fish: .. code-block:: fish - eval (env _COMPLETION_COMPLETE=source_fish completion) + eval (env _COMPLETION_COMPLETE=fish_source completion) Now press tab (maybe twice) after typing something to see completions. diff --git a/examples/completion/completion.py b/examples/completion/completion.py index abd09c0..6c45a1f 100644 --- a/examples/completion/completion.py +++ b/examples/completion/completion.py @@ -38,10 +38,13 @@ def list_users(ctx, param, incomplete): # of CompletionItem. You can match on whatever you want, including # the help. items = [("bob", "butcher"), ("alice", "baker"), ("jerry", "candlestick maker")] + out = [] for value, help in items: if incomplete in value or incomplete in help: - yield CompletionItem(value, help=help) + out.append(CompletionItem(value, help=help)) + + return out @group.command(help="Choose a user") -- cgit v1.2.1