Files
Minint/Report/lab2/newuml/render-png.sh
2026-04-10 02:21:47 +03:00

39 lines
1.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Rasterize PlantUML sources in this directory to PNG (ОЗ.Р1 / отчёт).
# Requires one of: plantuml in PATH, or Java + plantuml.jar (see below).
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# PNG рядом с исходником: oz-r1-foo.puml -> oz-r1-foo.png
OUT_OPTS=(-tpng)
run_plantuml() {
if command -v plantuml >/dev/null 2>&1; then
plantuml "${OUT_OPTS[@]}" "$@"
return 0
fi
local jar="${PLANTUML_JAR:-}"
if [[ -n "$jar" && -f "$jar" ]] && command -v java >/dev/null 2>&1; then
java -jar "$jar" "${OUT_OPTS[@]}" "$@"
return 0
fi
echo "plantuml не найден. Установите пакет (например plantuml) или задайте PLANTUML_JAR" >&2
echo " export PLANTUML_JAR=/path/to/plantuml.jar" >&2
echo "Скачать JAR: https://plantuml.com/download" >&2
return 127
}
shopt -s nullglob
sources=(*.puml)
if ((${#sources[@]} == 0)); then
echo "В $SCRIPT_DIR нет файлов *.puml" >&2
exit 0
fi
run_plantuml "${sources[@]}"
echo "Готово: PNG рядом с исходниками в $SCRIPT_DIR"