#!/bin/sh

#
# A simple script to run the uv project from another directory. Useful for testing.
# Make sure this is in your path (or create an alias for it) and you can run it from anywhere!

>&2 echo "Executes tgwrap from local source"

SCRIPT_DIR=$(dirname "$0")
ORIGINAL_CWD=$(pwd)
export OUTDATED_IGNORE=true

# Create a wrapper script that preserves the working directory
WRAPPER_SCRIPT=$(mktemp)
cat > "$WRAPPER_SCRIPT" << 'EOF'
#!/bin/sh
cd "$1" || exit 1
shift
exec tgwrap "$@"
EOF
chmod +x "$WRAPPER_SCRIPT"

# Execute via uv, passing the original directory and arguments
cd "$SCRIPT_DIR"
exec uv run "$WRAPPER_SCRIPT" "$ORIGINAL_CWD" "$@"
