#!/bin/bash
set -e
cd "$(dirname "$0")"

VERSION=$(cat VERSION | tr -d '[:space:]')
echo "[adom-shotlog] Building v${VERSION}..."

source "$HOME/.cargo/env" 2>/dev/null
cargo build --release 2>&1 | tail -1
sudo cp target/release/adom-shotlog /usr/local/bin/adom-shotlog
# Back-compat `shotlog` alias
sudo ln -sf /usr/local/bin/adom-shotlog /usr/local/bin/shotlog

echo "[adom-shotlog] Running install..."
adom-shotlog install

echo "[adom-shotlog] v${VERSION} built and installed (alias: shotlog)."