6fa931aa36
Testing / remote-protocol-compat (0.9.5) (push) Successful in 56s
Testing / remote-protocol-compat (0.9.3) (push) Successful in 59s
Testing / test (push) Successful in 1m1s
Build & Publish Package / publish (push) Successful in 33s
Package Extension / package-extension (push) Successful in 36s
- Gate TCP serve commands with safe-by-default policies, per-key allow tokens, per-key rate limiting, and audit labels. - Reuse authenticated encrypted remote sessions and parallelize/caches multi-browser fanout to reduce repeated handshake roundtrips. - Increase paged native-host batch size with extension-side byte budgeting to speed large tab listings safely. - Point install output at public Chrome Web Store / Firefox AMO listings by default, with --dev preserving unpacked workflows. - Share search-engine metadata between CLI and SDK and bump the package/extension version to 0.16.0. - Cover the new security, pooling, paging, install, and fanout behavior with expanded Python and extension tests.
29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
import click
|
|
from browser_cli.commands import client_from_ctx, handle_errors
|
|
from rich.console import Console
|
|
from browser_cli.search.engines import DISPLAY_NAMES, SUBCOMMANDS
|
|
|
|
console = Console()
|
|
|
|
@click.group("search")
|
|
def search_group():
|
|
"""Search the web — open a query in a search engine."""
|
|
|
|
def _build_command(engine_key: str, help_text: str) -> click.Command:
|
|
@click.command(engine_key, help=help_text)
|
|
@click.argument("query", nargs=-1, required=True)
|
|
@click.option("--window", "window", default=None, help="Open in named window")
|
|
@click.option("--group", "group", default=None, help="Open in tab group (name or ID)")
|
|
@handle_errors
|
|
def _cmd(query, window, group):
|
|
terms = " ".join(query)
|
|
client_from_ctx().nav.search(engine_key, terms, window=window, group=group)
|
|
suffix = f" in group '{group}'" if group else (f" in window '{window}'" if window else "")
|
|
display = DISPLAY_NAMES.get(engine_key, engine_key.capitalize())
|
|
console.print(f"[green]Searching[/green] [cyan]{display}[/cyan]: {terms}{suffix}")
|
|
|
|
return _cmd
|
|
|
|
for _name, _help in SUBCOMMANDS:
|
|
search_group.add_command(_build_command(_name, _help))
|