""" id: gh_tools title: GitHub CLI Wrapper author: admin description: Create PRs and comments using gh CLI in a repo. version: 0.1.0 license: Proprietary """ import subprocess class Tools: def pr_create( self, repo: str, title: str, body: str = "", base: str = "main", head: str = "" ) -> dict: cmd = ( f"gh pr create --repo {repo} --title {title!r} --body {body!r} --base {base} " + (f"--head {head} " if head else "") ) p = subprocess.run(["bash", "-lc", cmd], capture_output=True, text=True) return { "stdout": p.stdout, "stderr": p.stderr, "exit_code": p.returncode, "cmd": cmd, } def pr_comment(self, repo: str, pr_number: int, body: str) -> dict: cmd = f"gh pr comment {pr_number} --repo {repo} --body {body!r}" p = subprocess.run(["bash", "-lc", cmd], capture_output=True, text=True) return { "stdout": p.stdout, "stderr": p.stderr, "exit_code": p.returncode, "cmd": cmd, }