This commit is contained in:
2026-01-01 20:37:27 -08:00
parent f3c79609d8
commit deb05c0d44
35 changed files with 5030 additions and 4879 deletions

View File

@@ -11,9 +11,11 @@ from __future__ import annotations
import contextlib
import sys
from typing import Any, Iterator, TextIO
from typing import Any, Iterator, Sequence, TextIO
from rich.console import Console
from rich.panel import Panel
from rich.text import Text
# Configure Rich pretty-printing to avoid truncating long strings (hashes/paths).
# This is version-safe: older Rich versions may not support the max_* arguments.
@@ -70,3 +72,33 @@ def capture_rich_output(*, stdout: TextIO, stderr: TextIO) -> Iterator[None]:
finally:
_STDOUT_CONSOLE = previous_stdout
_STDERR_CONSOLE = previous_stderr
def show_provider_config_panel(
provider_name: str,
keys: Sequence[str] | None = None,
*,
config_hint: str = "config.conf"
) -> None:
"""Show a Rich panel explaining how to configure a provider."""
normalized = str(provider_name or "").strip() or "provider"
pre = Text("Add this to your config", style="bold")
footer = Text(
f"Place this block in {config_hint} or config.d/*.conf",
style="dim"
)
body = Text()
body.append(f"[provider={normalized}]\n", style="bold cyan")
for key in keys or []:
body.append(f'{key}=""\n', style="yellow")
stderr_console().print(pre)
stderr_console().print(
Panel(
body,
title=f"{normalized} configuration",
expand=False
)
)
stderr_console().print(footer)