diff --git a/click_repl/_completer.py b/click_repl/_completer.py index 08ef106..e16a4a9 100644 --- a/click_repl/_completer.py +++ b/click_repl/_completer.py @@ -230,6 +230,7 @@ def _get_completion_for_cmd_args( choices = self._get_completion_from_params( autocomplete_ctx, args, param, incomplete ) + break elif isinstance(param, click.Argument): choices.extend( diff --git a/tests/test_completion/test_common_tests/test_option_completion.py b/tests/test_completion/test_common_tests/test_option_completion.py index 38bf34e..c91f05c 100644 --- a/tests/test_completion/test_common_tests/test_option_completion.py +++ b/tests/test_completion/test_common_tests/test_option_completion.py @@ -14,12 +14,16 @@ def root_command(): def test_option_choices(): @root_command.command() @click.option("--handler", type=click.Choice(("foo", "bar"))) + @click.option("--wrong", type=click.Choice(("bogged", "bogus"))) def option_choices(handler): pass completions = list(c.get_completions(Document("option-choices --handler "))) assert {x.text for x in completions} == {"foo", "bar"} + completions = list(c.get_completions(Document("option-choices --wrong "))) + assert {x.text for x in completions} == {"bogged", "bogus"} + def test_boolean_option(): @root_command.command()