From dd798fda8719f7c86ccbd495b27c7910999d56d7 Mon Sep 17 00:00:00 2001 From: daijro Date: Sat, 7 Mar 2026 00:31:53 -0600 Subject: [PATCH] Support passing channels in remove & fetch cli --- pythonlib/camoufox/__main__.py | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/pythonlib/camoufox/__main__.py b/pythonlib/camoufox/__main__.py index d8d93f0..4873073 100644 --- a/pythonlib/camoufox/__main__.py +++ b/pythonlib/camoufox/__main__.py @@ -73,6 +73,8 @@ def _find_installed(specifier: str) -> Optional[InstalledVersion]: spec = specifier.lower() installed = list_installed() + parts = spec.split("/") + for v in installed: if any( [ @@ -83,14 +85,20 @@ def _find_installed(specifier: str) -> Optional[InstalledVersion]: ] ): return v + # Match repo/version without channel for example official/134.0.2-beta.20 + if len(parts) == 2: + repo, ver = parts + if v.repo_name == repo and v.version.full_string.lower() == ver: + return v - parts = spec.split("/") + # Match repo/channel for example official/stable gets latest installed for that channel if len(parts) == 2: repo, ctype = parts - is_pre = ctype == "prerelease" - for v in installed: - if v.repo_name == repo and v.is_prerelease == is_pre: - return v + if ctype in ("stable", "prerelease"): + is_pre = ctype == "prerelease" + for v in installed: + if v.repo_name == repo and v.is_prerelease == is_pre: + return v return None @@ -251,14 +259,21 @@ def fetch(version): config = load_config() if version: - if "/" not in version: + parts = version.split("/") + if len(parts) == 3: + # official/stable/135.0.1-beta.24 + repo_name = parts[0] + ver_str = parts[2].lstrip("v") + elif len(parts) == 2: + # official/135.0.1-beta.24 + repo_name = parts[0] + ver_str = parts[1].lstrip("v") + else: rprint( - "Format: /- (e.g., official/135.0-beta.25)", + "Format: / or //", fg="red", ) return - repo_name, ver_str = version.split("/", 1) - ver_str = ver_str.lstrip("v") elif config.get("pinned"): channel = config.get("channel", "") repo_name = channel.split("/")[0] if "/" in channel else channel