#!/bin/sh
#  Normies Yacht Club - your agent.
#
#  ⚠ ON macOS THIS FILE ARRIVES WITHOUT PERMISSION TO RUN, and only one command fixes that:
#       chmod +x run-agent.command
#  Run it once in Terminal, in this folder, and after that you can double-click this file.
#  We would remove that step if a browser were allowed to, and it is not.
cd "$(dirname "$0")" || exit 1
NYC_LAUNCHER=menu; export NYC_LAUNCHER
if ! command -v node >/dev/null 2>&1; then
  echo "  Node is not installed, and your agent needs it. Get it from https://nodejs.org"
  exit 1
fi
if [ ! -f orders.json ]; then
  echo "  orders.json is not in this folder. Put this file beside the orders from The Purser."
  exit 1
fi
echo ""
echo "  1  See what it would do, and send nothing"
echo "  2  Let it act, once, now"
echo ""
printf "  Type 1 or 2 then press Enter: "
read pick
if [ "$pick" = "2" ]; then
  [ -d node_modules/ethers ] || npm install ethers --no-audit --no-fund --loglevel=error
  node agent.js orders.json --send
else
  node agent.js orders.json
fi
