#!/bin/bash set -eu verbose=false offline= moar=true while [ "$#" -gt 0 ] && $moar; do case "$1" in verbose | -v | --verbose) verbose=true shift 1 ;; --offline) offline=--offline shift 1 ;; esac done hideok= if command -v chronic >/dev/null; then hideok=chronic fi quiet=-q if $verbose; then quiet= hideok= fi codegen() { target="$(cargo metadata --format-version=1 | python3 -c 'import sys, json; o = json.load(sys.stdin); print(o["target_directory"])')" $hideok subplot codegen "$1" --output "$2" rm -f test.log $hideok python3 test.py --log test.log --env "CARGO_TARGET_DIR=$target" } docgen() { subplot docgen "$1" --output "$2" } $hideok cargo build --all-targets $offline if cargo --list | awk '{ print $1 }' | grep 'clippy$' >/dev/null; then # shellcheck disable=SC2086 cargo clippy $quiet $offline fi # shellcheck disable=SC2086 $hideok cargo test $quiet $offline if cargo fmt --help >/dev/null 2>/dev/null; then $hideok cargo fmt -- --check fi for subplot in [^CR]*.subplot; do $hideok echo "$subplot =====================================" codegen "$subplot" test.py docgen "$subplot" "$(basename "$subplot" .subplot).html" $hideok echo done echo "Everything seems to be in order."