add basics

This commit is contained in:
2026-02-05 22:01:07 +01:00
parent 7e75de3298
commit 24d8c9c8af
7 changed files with 173 additions and 0 deletions
View File
+24
View File
@@ -0,0 +1,24 @@
import typer
from pathlib import Path
from jeAddons.registry import load_registry
from jeAddons.copier import fetch_file
app = typer.Typer()
@app.command()
def add(name: str):
registry = load_registry()
if name not in registry:
typer.echo(f"❌ Unknown entry: {name}")
raise typer.Exit(1)
entry = registry[name]
fetch_file(entry["repo"], entry["file"], Path.cwd())
typer.echo(f"✅ Added {entry['file']}")
if __name__ == "__main__":
app()
+16
View File
@@ -0,0 +1,16 @@
import subprocess
import tempfile
import shutil
from pathlib import Path
def fetch_file(repo_url: str, file_path: str, dest: Path):
tmp = tempfile.mkdtemp()
subprocess.check_call(["git", "clone", "--depth", "1", repo_url, tmp])
src = Path(tmp) / file_path
if not src.exists():
raise FileNotFoundError(file_path)
shutil.copy2(src, dest / src.name)
+9
View File
@@ -0,0 +1,9 @@
import json
import urllib.request
REGISTRY_URL = "https://raw.githubusercontent.com/acme/registry/main/registry.json"
def load_registry():
with urllib.request.urlopen(REGISTRY_URL) as r:
return json.load(r)