Emit selection menu to standard error
Marco Ricci

Marco Ricci commited on 2025-04-09 19:20:13
Zeige 1 geänderte Dateien mit 6 Einfügungen und 4 Löschungen.


Consider the heading and the menu printed before a prompt as diagnostic
information, and output it to standard error.
... ...
@@ -546,11 +546,13 @@ def prompt_for_selection(
546 546
     n = len(items)
547 547
     color = ctx.color if ctx is not None else None
548 548
     if heading:
549
-        click.echo(click.style(heading, bold=True), color=color)
549
+        click.echo(click.style(heading, bold=True), err=True, color=color)
550 550
     for i, x in enumerate(items, start=1):
551
-        click.echo(click.style(f'[{i}]', bold=True), nl=False, color=color)
552
-        click.echo(' ', nl=False, color=color)
553
-        click.echo(x, color=color)
551
+        click.echo(
552
+            click.style(f'[{i}]', bold=True), nl=False, err=True, color=color
553
+        )
554
+        click.echo(' ', nl=False, err=True, color=color)
555
+        click.echo(x, err=True, color=color)
554 556
     if n > 1:
555 557
         choices = click.Choice([''] + [str(i) for i in range(1, n + 1)])
556 558
         choice = click.prompt(
557 559