aboutsummaryrefslogtreecommitdiff
path: root/tools/link_toolchain.sh
diff options
context:
space:
mode:
authorLouis <louis@dnge.de>2026-11-11 10:11:21 +0100
committerLouis <louis@dnge.de>2026-11-11 10:11:50 +0100
commit6f2bbe1f94e4321c329f92ec3420f6d32fd7b26d (patch)
treecfa53d98d960421b6bcfd777d881629878d33b08 /tools/link_toolchain.sh
parent2e433fcd0d1afadd8ab786dd30d7d4546bdee43d (diff)
downloadhw-toolchain-6f2bbe1f94e4321c329f92ec3420f6d32fd7b26d.tar.gz
link_toolchain.sh: link the notes into a host repo as per-file symlinks
IWE follows file symlinks but not directory symlinks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tools/link_toolchain.sh')
-rw-r--r--tools/link_toolchain.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/link_toolchain.sh b/tools/link_toolchain.sh
new file mode 100644
index 0000000..8f488e1
--- /dev/null
+++ b/tools/link_toolchain.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+# Link the toolchain's notes into your repo's knowledge graph, one symlink per file (IWE and
+# other Markdown tools follow file symlinks, not directory symlinks).
+#
+# sh toolchain/tools/link_toolchain.sh [TOOLCHAIN_DIR] [--topics name ...]
+#
+# Run from your repo root. Links every knowledge/tooling/*.md of the toolchain into
+# knowledge/tooling/, and the topics named after --topics (default: all) into knowledge/topics/.
+# Existing regular files are left alone and reported; stale links into the toolchain are removed.
+set -e
+TC=${1:-toolchain}; [ $# -gt 0 ] && shift
+[ -d "$TC/knowledge/tooling" ] || { echo "no $TC/knowledge/tooling; pass the toolchain directory" >&2; exit 1; }
+TOPICS=""
+if [ "$1" = "--topics" ]; then shift; TOPICS="$*"; fi
+[ -n "$TOPICS" ] || TOPICS=$(cd "$TC/knowledge/topics" && ls *.md | sed 's/\.md$//')
+
+link() { # link SUBDIR NAME
+ mkdir -p "knowledge/$1"
+ dst="knowledge/$1/$2.md"
+ if [ -e "$dst" ] && [ ! -L "$dst" ]; then echo "kept (own file): $dst"; return; fi
+ ln -sfn "../../$TC/knowledge/$1/$2.md" "$dst"
+}
+
+for f in "$TC"/knowledge/tooling/*.md; do link tooling "$(basename "$f" .md)"; done
+for t in $TOPICS; do link topics "$t"; done
+for d in knowledge/tooling knowledge/topics; do
+ for l in "$d"/*.md; do [ -L "$l" ] && [ ! -e "$l" ] && { rm "$l"; echo "removed stale link: $l"; }; done
+done
+echo "linked $(ls "$TC"/knowledge/tooling/*.md | wc -l | tr -d ' ') tool notes"