Files
deck_in_a_dash/engine/scripts/run-interpreter.sh
T

85 lines
2.6 KiB
Bash

#!/bin/sh
# Runs deck-engine (--format json) piped straight into interpreter-cli for
# "today": same OS-clock seed/transit-moment and user.properties birth
# data as run-engine.sh, but reports how significant today's transits are
# instead of printing the full reading. Usage: ./run-interpreter.sh
#
# Requires both dist/deck-engine (built by engine/'s Makefile) and
# dist/interpreter-cli (built by interpreter/'s own Makefile) to already
# exist next to this script.
set -eu
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ENGINE_BINARY="$SCRIPT_DIR/deck-engine"
INTERPRETER_BINARY="$SCRIPT_DIR/interpreter-cli"
PROPERTIES_FILE="$SCRIPT_DIR/user.properties"
if [ ! -x "$ENGINE_BINARY" ]; then
echo "error: $ENGINE_BINARY not found or not executable (run 'make' in engine/ first)" >&2
exit 1
fi
if [ ! -x "$INTERPRETER_BINARY" ]; then
echo "error: $INTERPRETER_BINARY not found or not executable (run 'make' in interpreter/ first)" >&2
exit 1
fi
if [ ! -f "$PROPERTIES_FILE" ]; then
echo "error: $PROPERTIES_FILE not found" >&2
exit 1
fi
birth_date=""
birth_time=""
birth_utc_offset=""
birth_lat=""
birth_lon=""
while IFS='=' read -r key value || [ -n "$key" ]; do
key="$(printf '%s' "$key" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
value="$(printf '%s' "$value" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
case "$key" in
'' | '#'*) continue ;;
esac
case "$key" in
birth_date) birth_date="$value" ;;
birth_time) birth_time="$value" ;;
birth_utc_offset) birth_utc_offset="$value" ;;
birth_lat) birth_lat="$value" ;;
birth_lon) birth_lon="$value" ;;
esac
done <"$PROPERTIES_FILE"
check_set() {
case "$2" in
'' | *YOUR_*)
echo "error: $PROPERTIES_FILE: '$1' is not set - edit the file and fill in your details." >&2
exit 1
;;
esac
}
check_set birth_date "$birth_date"
check_set birth_time "$birth_time"
check_set birth_utc_offset "$birth_utc_offset"
check_set birth_lat "$birth_lat"
check_set birth_lon "$birth_lon"
# OS-provided inputs: today's date is the tarot seed (stable all day, a
# new spread each day), current UTC time drives today's transits. The
# tarot seed doesn't matter for --format json (only "transits" is read
# downstream) but it's kept identical to run-engine.sh's for consistency.
seed="$(date +%Y-%m-%d)"
transit_date="$(date -u +%Y-%m-%dT%H:%M)"
"$ENGINE_BINARY" \
--seed "$seed" \
--birth-date "$birth_date" \
--birth-time "$birth_time" \
--birth-utc-offset "$birth_utc_offset" \
--birth-lat "$birth_lat" \
--birth-lon "$birth_lon" \
--date "$transit_date" \
--format json \
| exec "$INTERPRETER_BINARY"