#!/bin/sh
# VICEDAQ CLI installer — https://vicedaq.live/docs
# Installs the `vicedaq` market-terminal CLI into ~/.local/bin.
set -eu

BASE="${VICEDAQ_API:-https://vicedaq.live}"
DEST="${VICEDAQ_BIN:-$HOME/.local/bin}"

echo "VICEDAQ · installing the market terminal CLI"
mkdir -p "$DEST"
if ! curl -fsSL "$BASE/vicedaq" -o "$DEST/vicedaq"; then
  echo "primary host unreachable, trying fallback..."
  curl -fsSL "https://vicedaq-production.up.railway.app/vicedaq" -o "$DEST/vicedaq"
fi
chmod +x "$DEST/vicedaq"

echo "installed: $DEST/vicedaq"
case ":$PATH:" in
  *":$DEST:"*) ;;
  *) echo "note: add it to your PATH:  export PATH=\"$DEST:\$PATH\"" ;;
esac
echo
echo "next steps:"
echo "  vicedaq psn link"
echo "  vicedaq market discover"
"$DEST/vicedaq" version
