feat: ADD work with local .env file #14

This commit is contained in:
Caffeine Fueled 2026-08-21 07:01:29 +02:00
parent 30e6956fa4
commit d0373f0198
Signed by: cf7
GPG key ID: CA295D643074C68C
4 changed files with 81 additions and 0 deletions

View file

@ -10,6 +10,20 @@ OUTPUT_DIR="output"
TEMPLATES_DIR="templates"
ASSETS_DIR="assets"
# Load .env if present; see .env.example for every option and its default.
# Precedence: command line flags > environment > .env > built-in defaults.
ENV_FILE="${ENV_FILE:-.env}"
if [[ -f "$ENV_FILE" ]]; then
# Remember caller-supplied values so the file cannot clobber them
env_override=$(export -p | grep -E '^declare -x (STRIP_EXIF|GALLERY_TITLE|SHOW_FOOTER)=' || true)
# shellcheck source=/dev/null
source "$ENV_FILE"
if [[ -n "$env_override" ]]; then
eval "$env_override"
fi
unset env_override
fi
# Image metadata (EXIF/GPS/IPTC/XMP) is stripped by default.
# Opt out with STRIP_EXIF=0 or --keep-exif.
STRIP_EXIF="${STRIP_EXIF:-1}"
@ -30,6 +44,9 @@ for arg in "$@"; do
echo " --keep-exif do not strip image metadata (env: STRIP_EXIF=0)"
echo " --no-footer hide the 'Powered by shellery' footer (env: SHOW_FOOTER=0)"
echo " --title=TEXT page title and header, default 'Gallery' (env: GALLERY_TITLE)"
echo ""
echo "Options may also be set in .env (see .env.example)."
echo "Precedence: flags > environment > .env > defaults."
exit 0 ;;
*) echo "unknown option: $arg" >&2; exit 1 ;;
esac