beffroi-reporting/beffroi.sh

73 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
usage() {
cat <<'EOF'
Usage:
./beffroi.sh report INPUT.yaml|json OUTPUT.pdf [--force]
./beffroi.sh diagnostic-pdf CAPTURE.json OUTPUT.pdf
./beffroi.sh capture-pdf CAPTURE OUTPUT.pdf
./beffroi.sh diagnostic CAPTURE EVIDENCE_ROOT OUTPUT_DIR REFERENCE_TIME [AUTHOR] [THEME]
./beffroi.sh all OUTPUT_DIR [--include-json] [--replace]
./beffroi.sh package BUILD_DIR ARTIFACT_DIR
./beffroi.sh test
./beffroi.sh bootstrap
./beffroi.sh doctor
EOF
exit "${1:-0}"
}
require() {
local missing=() command
for command in "$@"; do command -v "$command" >/dev/null 2>&1 || missing+=("$command"); done
((${#missing[@]} == 0)) || { echo "Missing tools: ${missing[*]}" >&2; exit 1; }
}
command_name=${1:-help}; shift || true
case "$command_name" in
report)
(($# >= 2))||usage 2; require typst
report_input=$1; report_output=$2; shift 2
reporter/render.sh "$report_input" --output "$report_output" "$@"
;;
diagnostic-pdf)
[[ $# -eq 2 ]]||usage 2; require typst
reports/plugins/diagnostics/render.sh "$1" --output "$2"
;;
capture-pdf)
[[ $# -eq 2 ]]||usage 2; require git typst
scripts/render-capture.sh "$1" "$2"
;;
diagnostic)
[[ $# -ge 4 && $# -le 6 ]]||usage 2; require git typst
scripts/workflow.sh all "$@"
;;
all)
(($# >= 1))||usage 2; require git typst
scripts/build-publication.sh "$@"
;;
package)
[[ $# -eq 2 ]]||usage 2; require uv
scripts/package-reports.sh "$1" "$2"
;;
test)
[[ $# -eq 0 ]]||usage 2; require git typst
scripts/check-components.sh
;;
bootstrap)
[[ $# -eq 0 ]]||usage 2; require git typst
./bootstrap.sh
;;
doctor)
[[ $# -eq 0 ]]||usage 2
require git typst
echo "Core tools are available."
for optional in uv; do
if command -v "$optional" >/dev/null 2>&1; then "$optional" --version 2>/dev/null | head -n 1 || true; else echo "Optional tool missing: $optional"; fi
done
;;
help|-h|--help) usage 0;;
*) usage 2;;
esac