upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/scripts/dev.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/dev.py')
-rw-r--r--scripts/dev.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/scripts/dev.py b/scripts/dev.py
index f0761d0c3..ffe2a0d9f 100644
--- a/scripts/dev.py
+++ b/scripts/dev.py
@@ -3,6 +3,8 @@
3 3
4import argparse 4import argparse
5import json 5import json
6import os
7import shlex
6import subprocess 8import subprocess
7import sys 9import sys
8from pathlib import Path 10from pathlib import Path
@@ -38,7 +40,7 @@ def discover() -> dict:
38 "id": name, 40 "id": name,
39 "path": path, 41 "path": path,
40 "present": present, 42 "present": present,
41 "help_argv": ["python", "-I", path, "--help"] if present else None, 43 "help_argv": [sys.executable, "-I", path, "--help"] if present else None,
42 "requirements": requirements, 44 "requirements": requirements,
43 }) 45 })
44 return { 46 return {
@@ -51,6 +53,13 @@ def discover() -> dict:
51 } 53 }
52 54
53 55
56def format_help_command(argv: list[str]) -> str:
57 if os.name == "nt":
58 quoted = ("'" + arg.replace("'", "''") + "'" for arg in argv)
59 return "& " + " ".join(quoted)
60 return shlex.join(argv)
61
62
54def run_producer(relative_path: str, args: list[str]) -> int: 63def run_producer(relative_path: str, args: list[str]) -> int:
55 producer = ROOT / relative_path 64 producer = ROOT / relative_path
56 if not producer.is_file(): 65 if not producer.is_file():
@@ -98,12 +107,13 @@ def main() -> int:
98 if args.json: 107 if args.json:
99 print(json.dumps(result, indent=2)) 108 print(json.dumps(result, indent=2))
100 else: 109 else:
110 sys.stdout.reconfigure(encoding="utf-8")
101 print("Paths and help commands are relative to the Leonida checkout root.") 111 print("Paths and help commands are relative to the Leonida checkout root.")
102 for tool in result["tools"]: 112 for tool in result["tools"]:
103 status = "present" if tool["present"] else "missing" 113 status = "present" if tool["present"] else "missing"
104 print(f"{tool['id']}: {tool['path']} ({status})") 114 print(f"{tool['id']}: {tool['path']} ({status})")
105 if tool["help_argv"]: 115 if tool["help_argv"]:
106 print(f" Help: {' '.join(tool['help_argv'])}") 116 print(f" Help: {format_help_command(tool['help_argv'])}")
107 print(" Requirements (not checked):") 117 print(" Requirements (not checked):")
108 for requirement in tool["requirements"]: 118 for requirement in tool["requirements"]:
109 print(f" - {requirement}") 119 print(f" - {requirement}")