90 lines
2.7 KiB
Bash
Executable File
90 lines
2.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Compose the pinned component CLIs without owning their implementation.
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
|
|
|
usage() {
|
|
cat >&2 <<'EOF'
|
|
Usage:
|
|
scripts/workflow.sh analyse CAPTURE EVIDENCE_ROOT OUTPUT REFERENCE_TIME
|
|
scripts/workflow.sh draft DIAGNOSTIC EVIDENCE_ROOT OUTPUT_DIR TITLE AUTHOR DATE
|
|
scripts/workflow.sh render REPORT OUTPUT
|
|
scripts/workflow.sh all CAPTURE EVIDENCE_ROOT WORK_DIR REFERENCE_TIME TITLE AUTHOR DATE
|
|
EOF
|
|
exit 2
|
|
}
|
|
|
|
require_values() {
|
|
for value in "$@"; do
|
|
[[ -n "$value" ]] || usage
|
|
done
|
|
}
|
|
|
|
diagnostic_python=.venv/component-checks/win-diagnostics/bin/python
|
|
report_python=.venv/component-checks/reportist/bin/python
|
|
for executable in "$diagnostic_python" "$report_python"; do
|
|
[[ -x "$executable" ]] || {
|
|
echo "Missing prepared environment: $executable" >&2
|
|
echo 'Run ./bootstrap.sh first.' >&2
|
|
exit 1
|
|
}
|
|
done
|
|
|
|
analyse() {
|
|
[[ $# -eq 4 ]] || usage
|
|
require_values "$@"
|
|
"$diagnostic_python" win-diagnostics/tools/analyse.py "$1" \
|
|
--evidence-root "$2" --output "$3" --reference-time "$4" \
|
|
--producer-version "$(git -C win-diagnostics rev-parse HEAD)"
|
|
}
|
|
|
|
draft() {
|
|
[[ $# -eq 6 ]] || usage
|
|
require_values "$@"
|
|
"$report_python" beffroi-reports/tools/diagnostic-to-report.py \
|
|
--diagnostic "$1" --evidence-root "$2" --output-dir "$3" \
|
|
--title "$4" --author "$5" --date "$6" \
|
|
--generator-version "$(git -C beffroi-reports rev-parse HEAD)" \
|
|
--diagnostic-validator win-diagnostics/tools/validate.py \
|
|
--report-validator reportist/tools/validate.py \
|
|
--branding beffroi-reports/config/branding/default.json \
|
|
--branding-root beffroi-reports
|
|
}
|
|
|
|
render() {
|
|
[[ $# -eq 2 ]] || usage
|
|
require_values "$@"
|
|
"$report_python" reportist/tools/render.py "$1" --output "$2"
|
|
}
|
|
|
|
command_name="${1:-}"
|
|
[[ -n "$command_name" ]] || usage
|
|
shift
|
|
case "$command_name" in
|
|
analyse) analyse "$@" ;;
|
|
draft) draft "$@" ;;
|
|
render) render "$@" ;;
|
|
all)
|
|
[[ $# -eq 7 ]] || usage
|
|
require_values "$@"
|
|
capture=$1
|
|
evidence_root=$2
|
|
work_dir=$3
|
|
reference_time=$4
|
|
title=$5
|
|
author=$6
|
|
report_date=$7
|
|
[[ ! -e "$work_dir" ]] || {
|
|
echo "$work_dir: work directory already exists" >&2
|
|
exit 1
|
|
}
|
|
mkdir -p "$work_dir"
|
|
analyse "$capture" "$evidence_root" "$work_dir/diagnostic.json" "$reference_time"
|
|
draft "$work_dir/diagnostic.json" "$evidence_root" "$work_dir/generation" \
|
|
"$title" "$author" "$report_date"
|
|
render "$work_dir/generation/report.draft.json" "$work_dir/report.pdf"
|
|
;;
|
|
*) usage ;;
|
|
esac
|