#!/usr/bin/env bash
set -euo pipefail

bin_dir="${HORIZON_INSTALL_DIR:-$HOME/.local/bin}"
base_url="${HORIZON_DOWNLOAD_BASE:-https://mail.myhorizon.co.za}"

mkdir -p "$bin_dir"
curl -fsSL "$base_url/hmail" -o "$bin_dir/hmail"
chmod +x "$bin_dir/hmail"

cat <<EOF
hmail installed to $bin_dir/hmail

Add this to your shell profile if needed:
  export PATH="$bin_dir:\$PATH"

Try:
  hmail auth.md
  hmail provision demo-agent
EOF
