feat: add batch report commands
This commit is contained in:
parent
b71c168a7f
commit
a41ba1bb87
|
|
@ -23,6 +23,12 @@ and DejaVu Sans Mono.
|
|||
bash tools/render.sh report.yaml --output report.pdf
|
||||
```
|
||||
|
||||
Render every YAML and JSON report in a directory tree with:
|
||||
|
||||
```bash
|
||||
bash tools/render-all.sh reports --output-dir output
|
||||
```
|
||||
|
||||
The renderer validates input before invoking Typst. It stages the report and its
|
||||
branding asset in an isolated temporary project, then publishes the completed
|
||||
PDF atomically. Existing output is rejected unless `--force` is explicit.
|
||||
|
|
@ -40,6 +46,8 @@ command name.
|
|||
bash tools/validate.sh examples/example-report.yaml
|
||||
```
|
||||
|
||||
Use `bash tools/validate-all.sh DIRECTORY` to validate a directory tree.
|
||||
|
||||
The version 1 format supports metadata, branding, summaries, timelines,
|
||||
findings, generic content sections, action plans, provenance, and appendices.
|
||||
See [docs/report-contract.md](docs/report-contract.md) and
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
|
||||
usage(){ echo "Usage: $0 INPUT_DIR --output-dir DIR [--force] [--typst COMMAND]" >&2; exit 2; }
|
||||
input_dir=${1:-}; [[ -n "$input_dir" ]]||usage; shift; output_dir= force=false; typst_command=
|
||||
while (($#)); do case $1 in --output-dir) (($# >= 2))||usage; output_dir=$2; shift 2;; --force) force=true; shift;; --typst) (($# >= 2))||usage; typst_command=$2; shift 2;; *) usage;; esac; done
|
||||
[[ -n "$output_dir" ]]||usage; input_dir=$(realpath "$input_dir"); mkdir -p "$output_dir"; output_dir=$(realpath "$output_dir")
|
||||
[[ "$output_dir" != "$input_dir" && "$output_dir" != "$input_dir"/* ]]||{ echo "output directory must be outside the input tree" >&2; exit 1; }
|
||||
count=0
|
||||
while IFS= read -r -d '' input; do
|
||||
relative=${input#"$input_dir/"}; output="$output_dir/$relative.pdf"; mkdir -p "$(dirname "$output")"
|
||||
arguments=(--output "$output"); [[ "$force" == false ]]||arguments+=(--force); [[ -z "$typst_command" ]]||arguments+=(--typst "$typst_command")
|
||||
"$root/tools/render.sh" "$input" "${arguments[@]}"; ((count+=1))
|
||||
done < <(find "$input_dir" -type f \( -name '*.json' -o -name '*.yaml' -o -name '*.yml' \) -print0 | sort -z)
|
||||
((count > 0))||{ echo "$input_dir: no YAML or JSON reports found" >&2; exit 1; }
|
||||
echo "Rendered $count reports into $output_dir"
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
|
||||
input_dir=${1:-}; [[ -n "$input_dir" && $# -eq 1 ]]||{ echo "Usage: $0 INPUT_DIR" >&2; exit 2; }
|
||||
count=0
|
||||
while IFS= read -r -d '' input; do "$root/tools/validate.sh" "$input"; ((count+=1)); done \
|
||||
< <(find "$input_dir" -type f \( -name '*.json' -o -name '*.yaml' -o -name '*.yml' \) -print0 | sort -z)
|
||||
((count > 0))||{ echo "$input_dir: no YAML or JSON reports found" >&2; exit 1; }
|
||||
echo "Validated $count reports"
|
||||
Loading…
Reference in New Issue