From 943cf4dbd205d11dad44d3d1d8f666e8702b6740 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sun, 12 Dec 2021 21:14:35 -0600 Subject: [PATCH] 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. --- src/rupert/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rupert/main.py b/src/rupert/main.py index 08dc533..20aa17a 100644 --- a/src/rupert/main.py +++ b/src/rupert/main.py @@ -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: