#!/bin/bash

# Get the directory of this script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TRACKER_DIR="$(dirname "$SCRIPT_DIR")"
EXE_PATH="$TRACKER_DIR/track_progress"
PY_PATH="$TRACKER_DIR/track_progress.py"

# Check if executable exists and is executable
if [ -x "$EXE_PATH" ]; then
    echo "Running Progress Tracker (executable version)..."
    "$EXE_PATH" "$@"
elif [ -f "$PY_PATH" ]; then
    echo "Executable not found, trying Python version..."
    echo "Running Progress Tracker (Python version)..."
    python "$PY_PATH" "$@"
else
    echo "Error: Neither executable nor Python script found at:"
    echo "- $EXE_PATH"
    echo "- $PY_PATH"
    exit 1
fi

EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ]; then
    echo "Progress tracking completed successfully!"
else
    echo "Error running progress tracker! (Exit code: $EXIT_CODE)"
fi
