#!/usr/bin/env bash # Compose diagnostic analysis with the independent diagnostic renderer. set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")/.." usage() { echo "Usage: $0 analyse CAPTURE EVIDENCE_ROOT OUTPUT.json REFERENCE_TIME" >&2 echo " $0 render REPORT.yaml|json OUTPUT.pdf" >&2 echo " $0 all CAPTURE EVIDENCE_ROOT NEW_OUTPUT_DIR REFERENCE_TIME [AUTHOR] [THEME]" >&2 exit 2 } command_name=${1:-}; [[ -n "$command_name" ]] || usage; shift case $command_name in analyse) [[ $# -eq 4 ]] || usage reports/plugins/diagnostics/analyse.sh "$1" --evidence-root "$2" --output "$3" \ --reference-time "$4" --producer-version "$(git -C reports rev-parse HEAD)" ;; render) [[ $# -eq 2 ]] || usage reporter/render.sh "$1" --output "$2" ;; all) [[ $# -ge 4 && $# -le 6 ]] || usage 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" reports/plugins/diagnostics/analyse.sh "$capture" --evidence-root "$evidence_root" \ --output "$output_dir/diagnostic.json" --reference-time "$reference_time" \ --producer-version "$(git -C reports rev-parse HEAD)" reports/plugins/diagnostics/render.sh "$capture" --output "$output_dir/report.pdf" \ --author "$author" --theme "$theme" ;; *) usage;; esac