#!/bin/bash

set -e  # Exit on any error

if ! command -v uv &> /dev/null
then
    echo "uv is not installed. Installing..."
    curl -LsSf https://astral.sh/uv/install.sh | sh
    echo "uv installation complete!"
    echo ""

    if [ -x ~/.local/bin/uv ]; then
        ~/.local/bin/uv tool install -U batrachian-toad --python 3.14
    else
        echo "Please restart your shell and run this script again"
        echo ""
        exit 0
    fi

else
    uv self update    
    uv tool install -U batrachian-toad --python 3.14
fi


echo ""
echo "For help and support, see the Toad Discussions board"
echo "https://github.com/batrachianai/toad/discussions"
echo ""
echo "Join the Textualize Discord server for realtime Toad chat"
echo "https://discord.gg/Enf6Z3qhVr"
echo ""
echo "Toad is installed!"
echo "Run 'toad' to launch"
