From fd8d757461be9fa1f3cbb728a8cb08c72571e719 Mon Sep 17 00:00:00 2001 From: Hardik Zinzuvadiya <25708027+Z4nzu@users.noreply.github.com> Date: Sun, 15 Mar 2026 18:13:37 +0530 Subject: [PATCH] Feature: Update command for each tool (option 3 in tool menu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit HackingTool: - Add update() method — detects install method from INSTALL_COMMANDS and runs the appropriate update: git clone → git -C pull pip install → pip install --upgrade go install → re-runs go install (fetches latest) gem install → gem update - Checks is_installed first; shows warning if not installed - Added as option 3 in every tool's OPTIONS menu (Install, Run, Update) --- core.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/core.py b/core.py index 5e3cd8e..bfe9780 100644 --- a/core.py +++ b/core.py @@ -109,6 +109,7 @@ class HackingTool: self.OPTIONS.append(("Install", self.install)) if runnable: self.OPTIONS.append(("Run", self.run)) + self.OPTIONS.append(("Update", self.update)) self.OPTIONS.extend(options) @property @@ -227,6 +228,46 @@ class HackingTool: def after_uninstall(self): pass + def update(self): + """Smart update — detects install method and runs the right update command.""" + if not self.is_installed: + console.print("[warning]Tool is not installed yet. Install it first.[/warning]") + return + + updated = False + for ic in (self.INSTALL_COMMANDS or []): + if "git clone" in ic: + # Extract repo dir name from clone command + parts = ic.split() + repo_urls = [p for p in parts if p.startswith("http")] + if repo_urls: + dirname = repo_urls[0].rstrip("/").rsplit("/", 1)[-1].replace(".git", "") + if os.path.isdir(dirname): + console.print(f"[cyan]→ git -C {dirname} pull[/cyan]") + os.system(f"git -C {dirname} pull") + updated = True + elif "pip install" in ic: + # Re-run pip install (--upgrade) + upgrade_cmd = ic.replace("pip install", "pip install --upgrade") + console.print(f"[cyan]→ {upgrade_cmd}[/cyan]") + os.system(upgrade_cmd) + updated = True + elif "go install" in ic: + # Re-run go install (fetches latest) + console.print(f"[cyan]→ {ic}[/cyan]") + os.system(ic) + updated = True + elif "gem install" in ic: + upgrade_cmd = ic.replace("gem install", "gem update") + console.print(f"[cyan]→ {upgrade_cmd}[/cyan]") + os.system(upgrade_cmd) + updated = True + + if updated: + console.print("[success]✔ Update complete![/success]") + else: + console.print("[dim]No automatic update method available for this tool.[/dim]") + def before_run(self): pass def run(self):