#!/bin/sh
# omher.app/omher - the short form of
#   curl -fsSL https://raw.githubusercontent.com/rlaope/oh-my-hermes/main/install.sh | sh -s -- omher
# It downloads that installer and runs it with omher: Hermes (when missing),
# OMH, then the omher desktop app. Usage: curl -fsSL https://omher.app/omher | sh
# Everything sits in one function called on the last line, so the shell has read
# the whole file before the installer starts reading the same stdin.
omher_main() {
  omher_f="$(mktemp "${TMPDIR:-/tmp}/omh-install.XXXXXX")" || exit 1
  if ! curl -fsSL https://raw.githubusercontent.com/rlaope/oh-my-hermes/main/install.sh -o "$omher_f"; then
    rm -f "$omher_f"
    printf 'omher: could not download the OMH installer\n' >&2
    exit 1
  fi
  sh "$omher_f" omher "$@"
  omher_rc=$?
  rm -f "$omher_f"
  exit "$omher_rc"
}
omher_main "$@"
