#!/bin/sh

set -eu
cd "${0%/*}/.."

image='ghcr.io/allisonkarlitskaya/toxbox'
opts=''

while [ $# != 0 ]; do
    case "$1" in
        --image=*)
            image="${1#--image=}"
            ;;
        --color)
            opts="${opts} -e FORCE_COLOR=1"
            ;;
        -it)
            opts="${opts} -it"
            ;;
        *)
            break
            ;;
    esac
    shift
done

if [ $# = 0 ]; then
    set tox -m toxbox
fi

set -x
podman run \
    ${opts} \
    --rm \
    --security-opt=label=disable \
    -v .:/src \
    -u tox \
    "${image}" "$@"
