feat(sec): initial release v1.0.0-alpha - ergonomic query routing engine

This commit is contained in:
2026-10-03 03:44:04 +03:00
commit db0997f934
24 changed files with 905 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
from rich.console import Console
from rich.panel import Panel
from rich.text import Text
try:
from sec.src.catalog import catalog
from sec.src.client import FetchResult
except ImportError:
from src.catalog import catalog
from src.client import FetchResult
class SnippetRenderer:
"""Renders cheat.sh responses in styled terminal format."""
def __init__(self, console: Console = None):
self.console = console or Console()
def render_not_found(self, query: str) -> None:
msg = catalog.format("status.not_found", query=query)
self.console.print(f"[dim]{msg}[/dim]")
def render_network_error(self) -> None:
msg = catalog.get("status.network_error")
self.console.print(f"[red]{msg}[/red]")
def render_clipboard_notice(self, is_all: bool) -> None:
key = "status.copied_all" if is_all else "status.copied_code"
msg = catalog.get(key)
self.console.print(f"[bold cyan]>> {msg}[/bold cyan]")
def render_result(self, result: FetchResult, copied: bool = False, is_all_copy: bool = False) -> None:
if result.is_cached:
cached_notice = catalog.get("status.offline_cached")
self.console.print(f"[yellow]{cached_notice}[/yellow]")
# Print content with native ANSI formatting
parsed_text = Text.from_ansi(result.content)
self.console.print(parsed_text)
if copied:
self.console.print("")
self.render_clipboard_notice(is_all_copy)