#!/usr/bin/env bash
# ===============================================================
#   TradeMind AI - Wrapper for macOS / Linux
#
#   Why this exists: pip's auto-generated `trademind` console script
#   wrapper can stay in use (and thus implicitly locked) while the
#   bot runs, causing `pip install --upgrade trademind-ai` to fail
#   with file-lock errors. This plain sh wrapper has no such issues:
#   it's an `exec python -m trademind.cli` and exits immediately,
#   releasing the file for the next upgrade.
#
#   Usage:
#     trademind                          -> start the bot
#     trademind --version                -> show version + license
#     trademind activate XXX-XXX-XXX-XX  -> activate a license
#     trademind update                   -> check for updates
# ===============================================================

# On modern macOS / Linux, `python` is often missing or aliased to nothing;
# only `python3` is reliably on PATH. Try python3 first, fall back to python.
if command -v python3 >/dev/null 2>&1; then
    PY=python3
elif command -v python >/dev/null 2>&1; then
    PY=python
else
    echo "trademind: Python no encontrado en PATH. Instalá Python 3.10+ y reintentá." >&2
    exit 1
fi

exec "$PY" -m trademind.cli "$@"