#!/usr/bin/env bash

# standard invocation of sitegen.py

set -e

source "$(dirname "$0")/common"

while getopts "t:r:p" OPT
do
    case "$OPT" in
      r)
        VERSION="$OPTARG"
        ;;
      t)
        ISABELLE_TOOL="$OPTARG"
        ;;
    esac
done
shift $((OPTIND-1))

set_isabelle_tool

echo "Checking metadata..."
"$ISABELLE_TOOL" afp_check_metadata || exit 2

echo "Checking ROOTs ..."
"$ISABELLE_TOOL" afp_check_roots -C chapter,groups,presence,roots,timeout || exit 2

echo "Building Isabelle components ..."

echo "Running sitegen ..."

"$ISABELLE_TOOL" afp_site_gen \
  -f \
  -H "$AFP_ROOT/out/hugo" \
  -O "$AFP_ROOT/web" \
  "$@"
