Skip to content

Commit

Permalink
Fix values shown for wrong option (#106)
Browse files Browse the repository at this point in the history
* fix values for wrong option

* add unit test
  • Loading branch information
ZanyMonk committed Jul 12, 2023
1 parent 12adb3b commit 79060f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions click_repl/_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 79060f1

Please sign in to comment.