remove planform and show extension version into client list
This commit is contained in:
+21
-4
@@ -86,6 +86,12 @@ def _print_version(ctx, param, value):
|
||||
ctx.exit()
|
||||
|
||||
|
||||
def _client_display_profile(profile_name: str, sock_path: str) -> str:
|
||||
if profile_name != "default":
|
||||
return profile_name
|
||||
return Path(sock_path).stem or profile_name
|
||||
|
||||
|
||||
@click.group()
|
||||
@click.option(
|
||||
"-V", "--version",
|
||||
@@ -136,14 +142,20 @@ def cmd_clients():
|
||||
|
||||
all_clients = []
|
||||
for profile_name, sock_path in profiles.items():
|
||||
display_profile = _client_display_profile(profile_name, sock_path)
|
||||
try:
|
||||
result = send_command("clients.list", profile=profile_name)
|
||||
for c in (result or []):
|
||||
c.setdefault("profile", profile_name)
|
||||
c["profile"] = display_profile
|
||||
all_clients.append(c)
|
||||
except (BrowserNotConnected, RuntimeError):
|
||||
# Socket registered but browser no longer connected
|
||||
all_clients.append({"profile": profile_name, "name": "—", "version": "—", "platform": "disconnected"})
|
||||
all_clients.append({
|
||||
"profile": display_profile,
|
||||
"name": "—",
|
||||
"version": "—",
|
||||
"extensionVersion": "disconnected",
|
||||
})
|
||||
|
||||
if not all_clients:
|
||||
console.print("[yellow]No browser clients found. Start a browser with the extension enabled first.[/yellow]")
|
||||
@@ -154,9 +166,14 @@ def cmd_clients():
|
||||
table.add_column("Profile")
|
||||
table.add_column("Browser")
|
||||
table.add_column("Version")
|
||||
table.add_column("Platform")
|
||||
table.add_column("Extension Version")
|
||||
for c in all_clients:
|
||||
table.add_row(c.get("profile", ""), c.get("name", ""), c.get("version", ""), c.get("platform", ""))
|
||||
table.add_row(
|
||||
c.get("profile", ""),
|
||||
c.get("name", ""),
|
||||
c.get("version", ""),
|
||||
c.get("extensionVersion", ""),
|
||||
)
|
||||
console.print(table)
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "browser-cli",
|
||||
"version": "0.5.0",
|
||||
"version": "0.5.1",
|
||||
"description": "Control your browser from the terminal via browser-cli",
|
||||
"permissions": [
|
||||
"tabs",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "browser-cli"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
description = "Control your real running browser from the terminal via a Chrome extension"
|
||||
requires-python = ">=3.10"
|
||||
dependencies = [
|
||||
|
||||
@@ -55,6 +55,35 @@ def test_clients_exits_cleanly_when_registry_is_missing():
|
||||
assert result.exit_code == 1
|
||||
assert "No browser clients found" in result.output
|
||||
|
||||
def test_clients_shows_named_profile_and_uses_socket_uuid_for_default(tmp_path):
|
||||
registry_path = tmp_path / "registry.json"
|
||||
default_socket = tmp_path / "550e8400-e29b-41d4-a716-446655440000.sock"
|
||||
work_socket = tmp_path / "work.sock"
|
||||
registry_path.write_text(
|
||||
'{"default": "%s", "work": "%s"}' % (default_socket, work_socket),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
responses = {
|
||||
"default": [{"profile": "default", "name": "Chrome", "version": "1", "extensionVersion": "2.3.4"}],
|
||||
"work": [{"profile": "default", "name": "Chrome", "version": "1", "extensionVersion": "2.3.4"}],
|
||||
}
|
||||
|
||||
def fake_send_command(command, args=None, profile=None):
|
||||
assert command == "clients.list"
|
||||
return responses[profile]
|
||||
|
||||
with patch("browser_cli.client.REGISTRY_PATH", registry_path), patch(
|
||||
"browser_cli.cli.send_command", side_effect=fake_send_command
|
||||
):
|
||||
result = CliRunner().invoke(main, ["clients"])
|
||||
|
||||
assert result.exit_code == 0
|
||||
assert "550e8400-e29b-41d4-a716-446655440000" in result.output
|
||||
assert "work" in result.output
|
||||
assert "Extension Version" in result.output
|
||||
assert "2.3.4" in result.output
|
||||
|
||||
def test_extract_markdown_command():
|
||||
with patch("browser_cli.commands.extract.send_command", return_value="# Title\n") as send_command:
|
||||
result = CliRunner().invoke(main, ["extract", "markdown"])
|
||||
|
||||
Reference in New Issue
Block a user