#!/bin/bash

# https://git.xslab.co.kr/hs-experimental-project/gyurinet-fastapi/-/blob/master/support/start-gyuri-fastapi.sh?ref_type=heads

if [ -z "$1" ]; then
  PKG="gyuri-fastapi"
else
  PKG="gyuri-fastapi[$1]"
fi


REQUIREMENTS_CONTENT=$(cat <<- EOF
--index-url https://pypi.gyuri.net/simple
$PKG
EOF
)

if [ -n "$2" ]; then
  echo "The argument must consist of one."
  exit 1
fi

echo "$REQUIREMENTS_CONTENT"

if ! grep "gyuri" requirements.txt; then
  echo -e "\n$REQUIREMENTS_CONTENT" >> requirements.txt
fi

if [ ! -d venv ]; then
  python3 -m venv venv
  . venv/bin/activate
fi

pip install --upgrade wheel setuptools wheel
pip install -r requirements.txt
