A .gitignore => .gitignore +1 -0
@@ 0,0 1,1 @@
+*.snippet.md
A Makefile => Makefile +5 -0
@@ 0,0 1,5 @@
+README.md: README.preamble.md README.snippet.md
+ cat $^ > $@
+
+README.snippet.md: scripts.toml scripts.py
+ ./scripts.py $@
M README.md => README.md +6 -1
@@ 1,3 1,8 @@
# rootmos' scripts
-[![builds.sr.ht status](https://builds.sr.ht/~rootmos/scripts.svg)](https://builds.sr.ht/~rootmos/scripts?)
+[![builds.sr.ht status](https://builds.sr.ht/~rootmos/scripts.svg)](https://builds.sr.ht/~rootmos/scripts)
+
+* term: Run a program in a new terminal or in the current terminal if available
+## ArchLinux management scripts
+* clean: Cleanup pacman cached, orphaned and/or explicitly installed packages, and coredumps
+* update: Update ArchLinux packages and rust, haskell, ocaml caches and nvim plugins
A README.preamble.md => README.preamble.md +4 -0
@@ 0,0 1,4 @@
+# rootmos' scripts
+
+[![builds.sr.ht status](https://builds.sr.ht/~rootmos/scripts.svg)](https://builds.sr.ht/~rootmos/scripts)
+
A scripts.py => scripts.py +50 -0
@@ 0,0 1,50 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+import tomllib
+import json
+
+script_dir = os.path.dirname(os.path.realpath(__file__))
+
+def run(scripts, o):
+ sections = {}
+ for k, v in scripts.get("section", {}).items():
+ sections[k] = v
+ if "scripts" not in v:
+ v["scripts"] = {}
+
+ for k, v in scripts.get("scripts", {}).items():
+ s = v.get("section") or ""
+ section = sections.get(s)
+ if section is None:
+ section = {"scripts": {}}
+ sections[s] = section
+ section["scripts"][k] = v
+
+ for _, section in (sorted(sections.items(), key=lambda i: i[0])):
+ t = section.get("title")
+ if t:
+ o.write("## " + t)
+ o.write("\n")
+
+ for fn, s in section.get("scripts", {}).items():
+ pass
+ o.write("* ")
+ o.write(fn)
+ d = s.get("description")
+ if d:
+ o.write(": ")
+ o.write(d)
+ o.write("\n")
+
+if __name__ == "__main__":
+ with open(os.path.join(script_dir, "scripts.toml"), "rb") as f:
+ scripts = tomllib.load(f)
+
+ try:
+ o = open(sys.argv[1], "w")
+ except IndexError:
+ o = sys.stdout
+
+ run(scripts, o)
A scripts.toml => scripts.toml +14 -0
@@ 0,0 1,14 @@
+[scripts.term]
+description = "Run a program in a new terminal or in the current terminal if available"
+
+
+[section.archlinux]
+title = "ArchLinux management scripts"
+
+[scripts.clean]
+section = "archlinux"
+description = "Cleanup pacman cached, orphaned and/or explicitly installed packages, and coredumps"
+
+[scripts.update]
+section = "archlinux"
+description = "Update ArchLinux packages and rust, haskell, ocaml caches and nvim plugins"