From 57c4ccc48a7fc1cbe9e3a1648aad5d22386680ed Mon Sep 17 00:00:00 2001 From: Daniel Dolezal Date: Fri, 10 Apr 2026 13:38:54 +0200 Subject: [PATCH] move rename-profile to clients rename --- README.md | 8 ++++---- browser_cli/cli.py | 17 ++++++++++++----- extension/manifest.json | 2 +- pyproject.toml | 2 +- tests/test_cli.py | 8 ++++---- uv.lock | 2 +- 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 8eb10e5..d2cf816 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ browser-cli/ All commands are run with `uv run browser-cli [--browser ALIAS] `. -If exactly one browser instance is connected, commands auto-target it. Use `--browser ALIAS` when multiple browser instances are connected. `tabs list`, `tabs count`, `groups list`, `groups count`, and `windows list` are the only commands that aggregate across all active browsers when `--browser` is omitted; in that mode they show the source browser alias or UUID. You can inspect the active instances with `browser-cli clients` and assign a persistent profile alias from inside the target browser with `browser-cli rename-profile --browser `. Closed browsers are removed from the client registry automatically. +If exactly one browser instance is connected, commands auto-target it. Use `--browser ALIAS` when multiple browser instances are connected. `tabs list`, `tabs count`, `groups list`, `groups count`, and `windows list` are the only commands that aggregate across all active browsers when `--browser` is omitted; in that mode they show the source browser alias or UUID. You can inspect the active instances with `browser-cli clients` and assign a persistent profile alias from inside the target browser with `browser-cli clients rename --browser `. Closed browsers are removed from the client registry automatically. Important: profile aliases are browser-instance aliases, not window aliases. Window aliases created with `windows rename` are only for targeting windows in commands like `nav open --window work`. If a browser instance has no explicit profile alias set, the native host gives it a generated UUID alias so multiple unaliased browsers stay distinct. @@ -271,8 +271,8 @@ browser-cli session auto-save off ```sh browser-cli clients # show connected browser info from the registry -browser-cli rename-profile --browser abcd1234 work # rename one connected browser instance -browser-cli --browser abcd1234 rename-profile work # equivalent global form +browser-cli clients rename --browser abcd1234 work # rename one connected browser instance +browser-cli --browser abcd1234 clients rename work # equivalent global form browser-cli install brave # (re)register the native host browser-cli completion zsh # print setup instructions browser-cli completion zsh --script # output raw completion script @@ -401,6 +401,6 @@ bash examples/demo.sh ## Limitations - **Chrome internal pages** (`chrome://`, `brave://`, `about:`) cannot be scripted. DOM and extract commands only work on regular `http://` and `https://` pages. -- **Multiple browser instances can be auto-distinguished, but generated aliases are temporary**. Unaliased browsers get UUID aliases from the native host, which avoids collisions but is less ergonomic than setting a stable alias with `browser-cli rename-profile --browser `. +- **Multiple browser instances can be auto-distinguished, but generated aliases are temporary**. Unaliased browsers get UUID aliases from the native host, which avoids collisions but is less ergonomic than setting a stable alias with `browser-cli clients rename --browser `. - **Supported install targets are explicit, not “all Chromium browsers”**. The installer currently supports Chrome, Chromium, Brave, Edge, and Vivaldi. Other Chromium-based browsers may use different or shared native messaging manifest locations, so they need browser-specific verification before being added safely. - **Linux and macOS only** — Windows native messaging paths are not yet handled. diff --git a/browser_cli/cli.py b/browser_cli/cli.py index 94ed9cb..6b063a5 100755 --- a/browser_cli/cli.py +++ b/browser_cli/cli.py @@ -121,9 +121,13 @@ main.add_command(search_group) # ── clients ──────────────────────────────────────────────────────────────────── -@main.command("clients") -def cmd_clients(): - """Show connected browser clients.""" +@click.group("clients", invoke_without_command=True) +@click.pass_context +def clients_group(ctx): + """Inspect and manage connected browser clients.""" + if ctx.invoked_subcommand is not None: + return + profiles: dict[str, str] = {} if REGISTRY_PATH.exists(): try: @@ -168,13 +172,16 @@ def cmd_clients(): console.print(table) -@main.command("rename-profile") +main.add_command(clients_group) + + +@clients_group.command("rename") @click.option( "--browser", "target_browser", default=None, metavar="ALIAS", help="Browser profile alias to rename. Overrides the global --browser option for this command.", ) @click.argument("alias") -def cmd_rename_profile(target_browser, alias): +def cmd_clients_rename(target_browser, alias): """Set the profile alias used to identify this browser instance.""" try: send_command("clients.rename_profile", {"alias": alias}, profile=target_browser) diff --git a/extension/manifest.json b/extension/manifest.json index ea3212b..fd9b582 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "browser-cli", - "version": "0.5.5", + "version": "0.5.6", "description": "Control your browser from the terminal via browser-cli", "permissions": [ "tabs", diff --git a/pyproject.toml b/pyproject.toml index 48459ec..05f970e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "browser-cli" -version = "0.5.5" +version = "0.5.6" description = "Control your real running browser from the terminal via a Chrome extension" requires-python = ">=3.10" dependencies = [ diff --git a/tests/test_cli.py b/tests/test_cli.py index 0933732..f6c0f0e 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -29,16 +29,16 @@ def test_project_version_falls_back_to_installed_package_metadata(): ): assert _project_version() == "9.9.9" -def test_rename_profile_uses_command_level_browser_target(): +def test_clients_rename_uses_command_level_browser_target(): with patch("browser_cli.cli.send_command") as send_command: - result = CliRunner().invoke(main, ["rename-profile", "--browser", "old-id", "work"]) + result = CliRunner().invoke(main, ["clients", "rename", "--browser", "old-id", "work"]) assert result.exit_code == 0 send_command.assert_called_once_with("clients.rename_profile", {"alias": "work"}, profile="old-id") -def test_rename_profile_uses_global_browser_target_when_set(): +def test_clients_rename_uses_global_browser_target_when_set(): with patch("browser_cli.cli.send_command") as send_command: - result = CliRunner().invoke(main, ["--browser", "old-id", "rename-profile", "work"]) + result = CliRunner().invoke(main, ["--browser", "old-id", "clients", "rename", "work"]) assert result.exit_code == 0 send_command.assert_called_once_with("clients.rename_profile", {"alias": "work"}, profile=None) diff --git a/uv.lock b/uv.lock index 60ee6d5..480c8be 100644 --- a/uv.lock +++ b/uv.lock @@ -4,7 +4,7 @@ requires-python = ">=3.10" [[package]] name = "browser-cli" -version = "0.5.4" +version = "0.5.6" source = { editable = "." } dependencies = [ { name = "click" },