#!/usr/bin/env bash
# Local build + install for adom-mouser.
set -euo pipefail

cd "$(dirname "$0")"

echo "==> cargo build --release"
cargo build --release

BIN=target/release/adom-mouser
if [ ! -x "$BIN" ]; then
  echo "ERROR: build did not produce $BIN" >&2
  exit 1
fi

DEST=/usr/local/bin/adom-mouser
echo "==> installing $DEST (sudo)"
sudo install -m 0755 "$BIN" "$DEST"

echo "==> adom-mouser install (skill + completions)"
adom-mouser install

echo
echo "Done. Try:"
echo "  adom-mouser --help"
echo "  adom-mouser search 'STM32F103'"
echo "  adom-mouser app"