# Application Environment Setup
# NOTICE:
#  - this file is meant to be sourced not executed

env="mpb"

# check for .env file and source it if we have it.
if [ -e .env ]; then
  echo "Found .env file, sourcing it..."
  source .env
fi
if [ "${BASH_SOURCE[0]}" != "${0}" ]; then
  # Script is properly being sourced
  echo "Activating Environment: ${env}"
  source .venv/bin/activate
else
  echo "ERROR: this script must be sourced not executed."
  echo " - please call as: $ source sw5env"
  echo "Cannot continue!"
  exit 1
fi

RED="\[\033[0;31m\]"
YELLOW="\[\033[1;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[1;34m\]"
PURPLE="\[\033[0;35m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"

# envvars
export cdb="http://admin:couchdb@localhost:5984"   # pragma: allowlist secret

# aliases
alias dc='docker-compose -f docker-compose.yml'
alias db='http ${cdb}/'

# functions
help() {
    echo "\
- help: show this help message
- dc: alias for docker-compose
"
}

# set prompt
export PS1="${LIGHT_GREEN}[${env}] \W\$ ${COLOR_NONE}"

echo " - environment activated, to deactivate exit this shell"
echo "Use 'help' to view commands."
