#!/usr/bin/env bash

unset HOST
export DETAILED_LOGGING=true
export LOG_ALL=true
export LOGLEVEL=info
export DUMMY_LOGIN=true
export ALLOW_DEPRECATED=true
export PWFILE=users.yml

move-back() {
    mv -v .stack-work .stack-work-run
    [[ -d .stack-work-build ]] && mv -v .stack-work-build .stack-work
}

if [[ -d .stack-work-run ]]; then
    [[ -d .stack-work ]] && mv -v .stack-work .stack-work-build
    mv -v .stack-work-run .stack-work
    trap move-back EXIT
fi

stack exec -- yesod devel $@
