move rename-profile to clients rename
This commit is contained in:
@@ -122,7 +122,7 @@ browser-cli/
|
|||||||
|
|
||||||
All commands are run with `uv run browser-cli [--browser ALIAS] <command>`.
|
All commands are run with `uv run browser-cli [--browser ALIAS] <command>`.
|
||||||
|
|
||||||
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 <current-alias> <new-alias>`. 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 <current-alias> <new-alias>`. 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.
|
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
|
```sh
|
||||||
browser-cli clients # show connected browser info from the registry
|
browser-cli clients # show connected browser info from the registry
|
||||||
browser-cli rename-profile --browser abcd1234 work # rename one connected browser instance
|
browser-cli clients rename --browser abcd1234 work # rename one connected browser instance
|
||||||
browser-cli --browser abcd1234 rename-profile work # equivalent global form
|
browser-cli --browser abcd1234 clients rename work # equivalent global form
|
||||||
browser-cli install brave # (re)register the native host
|
browser-cli install brave # (re)register the native host
|
||||||
browser-cli completion zsh # print setup instructions
|
browser-cli completion zsh # print setup instructions
|
||||||
browser-cli completion zsh --script # output raw completion script
|
browser-cli completion zsh --script # output raw completion script
|
||||||
@@ -401,6 +401,6 @@ bash examples/demo.sh
|
|||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
- **Chrome internal pages** (`chrome://`, `brave://`, `about:`) cannot be scripted. DOM and extract commands only work on regular `http://` and `https://` pages.
|
- **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 <current-alias> <new-alias>`.
|
- **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 <current-alias> <new-alias>`.
|
||||||
- **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.
|
- **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.
|
- **Linux and macOS only** — Windows native messaging paths are not yet handled.
|
||||||
|
|||||||
+12
-5
@@ -121,9 +121,13 @@ main.add_command(search_group)
|
|||||||
|
|
||||||
# ── clients ────────────────────────────────────────────────────────────────────
|
# ── clients ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@main.command("clients")
|
@click.group("clients", invoke_without_command=True)
|
||||||
def cmd_clients():
|
@click.pass_context
|
||||||
"""Show connected browser clients."""
|
def clients_group(ctx):
|
||||||
|
"""Inspect and manage connected browser clients."""
|
||||||
|
if ctx.invoked_subcommand is not None:
|
||||||
|
return
|
||||||
|
|
||||||
profiles: dict[str, str] = {}
|
profiles: dict[str, str] = {}
|
||||||
if REGISTRY_PATH.exists():
|
if REGISTRY_PATH.exists():
|
||||||
try:
|
try:
|
||||||
@@ -168,13 +172,16 @@ def cmd_clients():
|
|||||||
console.print(table)
|
console.print(table)
|
||||||
|
|
||||||
|
|
||||||
@main.command("rename-profile")
|
main.add_command(clients_group)
|
||||||
|
|
||||||
|
|
||||||
|
@clients_group.command("rename")
|
||||||
@click.option(
|
@click.option(
|
||||||
"--browser", "target_browser", default=None, metavar="ALIAS",
|
"--browser", "target_browser", default=None, metavar="ALIAS",
|
||||||
help="Browser profile alias to rename. Overrides the global --browser option for this command.",
|
help="Browser profile alias to rename. Overrides the global --browser option for this command.",
|
||||||
)
|
)
|
||||||
@click.argument("alias")
|
@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."""
|
"""Set the profile alias used to identify this browser instance."""
|
||||||
try:
|
try:
|
||||||
send_command("clients.rename_profile", {"alias": alias}, profile=target_browser)
|
send_command("clients.rename_profile", {"alias": alias}, profile=target_browser)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "browser-cli",
|
"name": "browser-cli",
|
||||||
"version": "0.5.5",
|
"version": "0.5.6",
|
||||||
"description": "Control your browser from the terminal via browser-cli",
|
"description": "Control your browser from the terminal via browser-cli",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"tabs",
|
"tabs",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "browser-cli"
|
name = "browser-cli"
|
||||||
version = "0.5.5"
|
version = "0.5.6"
|
||||||
description = "Control your real running browser from the terminal via a Chrome extension"
|
description = "Control your real running browser from the terminal via a Chrome extension"
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|||||||
+4
-4
@@ -29,16 +29,16 @@ def test_project_version_falls_back_to_installed_package_metadata():
|
|||||||
):
|
):
|
||||||
assert _project_version() == "9.9.9"
|
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:
|
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
|
assert result.exit_code == 0
|
||||||
send_command.assert_called_once_with("clients.rename_profile", {"alias": "work"}, profile="old-id")
|
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:
|
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
|
assert result.exit_code == 0
|
||||||
send_command.assert_called_once_with("clients.rename_profile", {"alias": "work"}, profile=None)
|
send_command.assert_called_once_with("clients.rename_profile", {"alias": "work"}, profile=None)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ requires-python = ">=3.10"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "browser-cli"
|
name = "browser-cli"
|
||||||
version = "0.5.4"
|
version = "0.5.6"
|
||||||
source = { editable = "." }
|
source = { editable = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "click" },
|
{ name = "click" },
|
||||||
|
|||||||
Reference in New Issue
Block a user