#!/usr/bin/python3 import json, os, subprocess, sys rid = sys.argv[1] p = subprocess.run(["rad", "config", "show"], check=True, capture_output=True) if p.returncode != 0: sys.exit("rad config show failed") config = json.loads(p.stdout.decode()) config["web"]["pinned"]["repositories"].append(rid) p = subprocess.run(["rad", "self", "--home"], check=True, capture_output=True) if p.returncode != 0: sys.exit("rad self --home failed") home = p.stdout.decode().strip() filename = os.path.join(home, "config.json") if os.path.exists(filename): os.rename(filename, filename + ".bak") with open(filename, "w") as f: f.write(json.dumps(config, indent=4))