#!/bin/bash

export DMOJ_IN_DOCKER=1
export PYTHONUNBUFFERED=1
export LANG=C.UTF-8
export PYTHONIOENCODING=utf8

cd /judge || exit
pip3 install -q -e .

case "$1" in
run) command=(dmoj) ;;
cli) command=(dmoj-cli) ;;
test) command=(python3 -- -m dmoj.testsuite testsuite) ;;
*)
  echo "Invalid command, must be one of [run, cli, test]" 1>&2
  exit 1
  ;;
esac

shift
. ~judge/.profile
runuser -u judge "${command[@]}" -- "$@"
