#!/bin/sh

usage() {
    cat <<EOF
usage: ${0##*/} [command]
    -h          Print this help message.
    -a          Run API.
    -i          Install.
    -d          Run docker-compose.
EOF
    exit 1
}

RUN=
while getopts "hadi" OPTION; do
    case $OPTION in
    a) RUN=api ;;
    d) RUN=docker ;;
    i) RUN=install ;;
    *) usage ;;
    esac
done

if [ "$RUN" = 'install' ]; then
    poetry install
elif [ "$RUN" = 'api' ]; then
    poetry shell
    uvicorn api.api:app --host 0.0.0.0
else
    docker-compose up
fi