main: prompt_menu: Print prompt text on stderr

The `rich.prompt.Prompt.ask` method does not print the prompt text on
the console provided.  It simply calls the built-in `input` function.
The `input` function is broken and unconditionally prints the prompt
text to standard output.

To work around both of these dumb limitations, we need to print the
prompt text ourselves and pass an empty string to `Prompt.ask` to avoid
printing anything on stdout that doesn't belong.
pull/3/head
Dustin 2021-12-12 21:14:35 -06:00
parent e8652cc813
commit 943cf4dbd2
1 changed files with 2 additions and 1 deletions

View File

@ -95,7 +95,8 @@ def prompt_menu(console: Console, choices: Iterable[Any]) -> int:
console.print(f'[bright_yellow]{idx + 1})[/bright_yellow]: {choice}')
max_ += 1
while 1:
choice = Prompt.ask('Selection', console=console)
console.print('Selection: ', end='')
choice = Prompt.ask('', console=console)
try:
i = int(choice)
except ValueError: