tools/generate.sh
30 lines · 1077 bytes · executable
1#!/usr/bin/env bash
2# Regenerate cases/<name>.html and cases/<name>.skeleton from orgo.
3#
4# The golden outputs are derived from orgo, the reference implementation — never edited by
5# hand. Point ORGO_DIR at an orgo checkout (default: ../orgo). Each case's .org input is
6# the source of truth for the input; this script only refreshes the two derived files.
7#
8# ORGO_DIR=../orgo tools/generate.sh
9set -euo pipefail
10
11here="$(cd "$(dirname "$0")/.." && pwd)"
12orgo="${ORGO_DIR:-$here/../orgo}"
13
14if [ ! -f "$orgo/Cargo.toml" ]; then
15 echo "orgo checkout not found at $orgo (set ORGO_DIR)" >&2
16 exit 1
17fi
18
19# One release-less build up front so the per-case runs are fast.
20( cd "$orgo" && cargo build -q --example skeleton )
21
22count=0
23for org in "$here"/cases/*.org; do
24 name="$(basename "$org" .org)"
25 ( cd "$orgo" && cargo run -q --example skeleton -- --html "$org" ) > "$here/cases/$name.html"
26 ( cd "$orgo" && cargo run -q --example skeleton -- "$org" ) > "$here/cases/$name.skeleton"
27 count=$((count + 1))
28 echo " regenerated $name"
29done
30echo "done: $count cases"