beffroi-reporting/beffroi.sh

62 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
usage() {
cat <<'EOF'
Usage:
./beffroi.sh report INPUT OUTPUT.pdf
./beffroi.sh diagnostic CAPTURE EVIDENCE_ROOT OUTPUT_DIR REFERENCE_TIME TITLE AUTHOR DATE
./beffroi.sh all NEW_OUTPUT_DIR
./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)
[[ $# -eq 2 ]]||usage 2; require typst
reporter/render.sh "$1" --output "$2"
;;
diagnostic)
[[ $# -eq 7 ]]||usage 2; require git typst
scripts/workflow.sh all "$@"
;;
all)
[[ $# -eq 1 ]]||usage 2; require git typst
scripts/build-publication.sh "$1"
;;
package)
[[ $# -eq 2 ]]||usage 2; require uv
scripts/package-reports.sh "$1" "$2"
;;
test)
[[ $# -eq 0 ]]||usage 2; require git typst uv
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