Skip to content

Commit

Permalink
feat: cli prompts now allow arrow keys to navigate choices
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpavlock committed Oct 12, 2022
1 parent eb947b9 commit 78344f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion moe/util/cli/prompt.py
Expand Up @@ -62,7 +62,9 @@ def choice_prompt(
)
)

user_input = questionary.rawselect(question, choices=questionary_choices).ask()
user_input = questionary.select(
question, choices=questionary_choices, use_shortcuts=True, use_arrow_keys=True
).ask()

for prompt_choice in prompt_choices:
if prompt_choice.shortcut_key == user_input:
Expand Down
4 changes: 2 additions & 2 deletions tests/util/cli/test_prompt.py
Expand Up @@ -20,7 +20,7 @@ def test_prompt_choice_return(self):
assert track.title != "a"

with patch(
"moe.util.cli.prompt.questionary.rawselect",
"moe.util.cli.prompt.questionary.select",
**{"return_value.ask.return_value": "a"}
):
prompt_choice = choice_prompt([mock_choice1, mock_choice2])
Expand All @@ -33,7 +33,7 @@ def test_invalid_input(self):
mock_choice = PromptChoice("title b", "b", lambda b: None)

with patch(
"moe.util.cli.prompt.questionary.rawselect",
"moe.util.cli.prompt.questionary.select",
**{"return_value.ask.return_value": "a"}
):
with pytest.raises(SystemExit) as error:
Expand Down

0 comments on commit 78344f9

Please sign in to comment.