diff options
author | Freya Murphy <freya@freyacat.org> | 2024-12-23 22:14:44 -0500 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-12-23 22:14:44 -0500 |
commit | 45b58da72187a7b1ed4d75fc25bf5dd59a86a9c4 (patch) | |
tree | 721d43e663d0b9d7c15ebc4b180ba709e9e0f9c3 /bin/psql | |
parent | lang null check (diff) | |
download | crimson-45b58da72187a7b1ed4d75fc25bf5dd59a86a9c4.tar.gz crimson-45b58da72187a7b1ed4d75fc25bf5dd59a86a9c4.tar.bz2 crimson-45b58da72187a7b1ed4d75fc25bf5dd59a86a9c4.zip |
rework tooling to make environement loading easier
Diffstat (limited to '')
-rwxr-xr-x | bin/psql (renamed from psql) | 23 |
1 files changed, 9 insertions, 14 deletions
@@ -25,21 +25,16 @@ # database at times. This makes it nicer enter it since you dont have to type # the full command. :) -# ================================================================ CONSTANTS == -# ROOT: This is the folder the crimson project is located in. ROOT is used to -# load the crimson environment. We need this since that is where POSTGRES_USER -# and POSTGRES_DB are stored. -# CALL_ROOT: This is the folder that the user who called `compose` is currently -# in. For crimson to work this must be the folder that your project using -# crimson is. This is because crimson loads `.env` here to load any user -# specified environment. `.env` is needed in cause you override POSTGRES_USER -# and/or POSTGRES_DB. -ROOT="$(dirname "$0")" -CALL_ROOT="$(pwd)" +# Make sure errors fail to avoid nasal demons +set -e + +# ========================================================= LOAD ENVIRONMENT == +# We need to load the environment variables provided by crimson and the user +# making the project. +SCRIPT_DIR="$(dirname "$0")" +source "$SCRIPT_DIR/setup_env" # ================================================================ BOOTSTRAP == # Load `base.env` and `.env`, then launch psql in docker. -source "$ROOT/base.env" -source "$CALL_ROOT/.env" -$ROOT/compose exec postgres psql -U "${POSTGRES_USER}" "${POSTGRES_DB}" "$@" +$SCRIPT_DIR/compose exec postgres psql -U "${POSTGRES_USER}" "${POSTGRES_DB}" "$@" |