summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2023-05-02 10:27:54 +0300
committerYuval Adam <_@yuv.al>2023-05-02 10:27:54 +0300
commit22609ad8dd38416faee673c229c738c0ad645940 (patch)
tree6860716b9b1cddf49c61b6334ba446fe89e73e20 /cli
parent6de7cb6ec533c9917441cbd4b9a1807f8f1cbe16 (diff)
Migrate ghpr script
Diffstat (limited to 'cli')
-rw-r--r--cli/__init__.py1
-rw-r--r--cli/ghpr.py51
2 files changed, 29 insertions, 23 deletions
diff --git a/cli/__init__.py b/cli/__init__.py
index 0b67a9e..e2ac2c7 100644
--- a/cli/__init__.py
+++ b/cli/__init__.py
@@ -2,4 +2,5 @@ from .base import cli
from .build import build
from .clean import clean
+from .ghpr import ghpr
from .scan import scan
diff --git a/cli/ghpr.py b/cli/ghpr.py
index 6c9f7f9..05c08ad 100644
--- a/cli/ghpr.py
+++ b/cli/ghpr.py
@@ -1,35 +1,40 @@
+import click
import sys
from pathlib import Path
from subprocess import run
+from .base import cli
+
ROOT_PATH = Path(__file__).parents[1]
-path = sys.argv[1]
-with open(path, "r") as f:
- for line in f:
- l = line.strip().split(",")
- domain, handle, name = [x.strip() for x in l]
- handle = None if "@" in handle else handle
+@cli.command()
+@click.argument("path", type=click.Path())
+def ghpr(path):
+ with open(path, "r") as f:
+ for line in f:
+ l = line.strip().split(",")
+ domain, handle, name = [x.strip() for x in l]
+ handle = None if "@" in handle else handle
- fn = domain.replace(".", "")
+ fn = domain.replace(".", "")
- path = ROOT_PATH / "names" / f"{fn}.yml"
- if path.exists():
- print(f"{domain} already exists")
- continue
+ path = ROOT_PATH / "names" / f"{fn}.yml"
+ if path.exists():
+ print(f"{domain} already exists")
+ continue
- with open(path, "w") as out:
- s = f"domain: {domain}\nname: {name}\n"
- if handle:
- s += f"github: {handle}\n"
- s += "candidate: true\n"
- out.write(s)
+ with open(path, "w") as out:
+ s = f"domain: {domain}\nname: {name}\n"
+ if handle:
+ s += f"github: {handle}\n"
+ s += "candidate: true\n"
+ out.write(s)
- # run(["git", "checkout", "-b", domain])
- # run(["git", "add", f"names/{fn}.yml"])
- # run(["git", "commit", "-m", f"Add {domain}"])
- # run(["git", "push", "-u", "origin", domain])
- # run(["gh", "pr", "create", "-t", f"Add {domain}", "-b", f"Hey @{handle}, would you like to merge this PR adding you to https://namehack.club?"])
- # run(["git", "checkout", "main"])
+ # run(["git", "checkout", "-b", domain])
+ # run(["git", "add", f"names/{fn}.yml"])
+ # run(["git", "commit", "-m", f"Add {domain}"])
+ # run(["git", "push", "-u", "origin", domain])
+ # run(["gh", "pr", "create", "-t", f"Add {domain}", "-b", f"Hey @{handle}, would you like to merge this PR adding you to https://namehack.club?"])
+ # run(["git", "checkout", "main"])