108 lines
3.0 KiB
Bash
Executable File
108 lines
3.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 consumables INPUT.csv OUTPUT.pdf [--force] [--theme NAME]
|
|
./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/build.sh render report "$report_input" --output "$report_output" "$@"
|
|
;;
|
|
consumables)
|
|
(($# >= 2)) || usage 2
|
|
require typst
|
|
consumables_input=$1
|
|
consumables_output=$2
|
|
shift 2
|
|
reporter/build.sh render consumables "$consumables_input" --output "$consumables_output" "$@"
|
|
;;
|
|
diagnostic-pdf)
|
|
[[ $# -eq 2 ]] || usage 2
|
|
require typst
|
|
reporter/build.sh render diagnostic "$1" --output "$2"
|
|
;;
|
|
capture-pdf)
|
|
[[ $# -eq 2 ]] || usage 2
|
|
require typst
|
|
reporter/build.sh render diagnostic "$1" --output "$2"
|
|
;;
|
|
diagnostic)
|
|
[[ $# -ge 4 && $# -le 6 ]] || usage 2
|
|
require git typst
|
|
capture=$1 evidence_root=$2 output_dir=$3 reference_time=$4
|
|
author=${5:-${DIAGNOSTICS_AUTHOR:-Beffroi}}
|
|
theme=${6:-${DIAGNOSTICS_THEME:-default}}
|
|
[[ ! -e "$output_dir" ]] || {
|
|
echo "$output_dir: output directory exists" >&2
|
|
exit 1
|
|
}
|
|
mkdir -p "$output_dir"
|
|
reporter/build.sh analyze "$capture" --evidence-root "$evidence_root" \
|
|
--output "$output_dir/diagnostic.json" --reference-time "$reference_time" \
|
|
--producer-version "$(git -C reporter rev-parse HEAD)"
|
|
reporter/build.sh render diagnostic "$capture" --output "$output_dir/report.pdf" \
|
|
--author "$author" --theme "$theme"
|
|
;;
|
|
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
|