#!/bin/bash
# Taskmaster Tracker Demo Script
# Demonstrates how to use the tracker in watch mode

set -e

# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"

echo "🎯 Taskmaster Tracker Demo"
echo "=========================="
echo ""
echo "This demo will show you how the Taskmaster tracker automatically"
echo "adds timestamps to tasks when they're created or status changes."
echo ""
echo "The tracker will:"
echo "  ✅ Add 'created_at' timestamps to new tasks"
echo "  ✅ Add 'updated_at' timestamps when tasks change"
echo "  ✅ Add 'status_changed_to_X' timestamps for status changes"
echo "  ✅ Create backups before making changes"
echo "  ✅ Log all activities"
echo ""

# Check if tracker script exists
TRACKER_SCRIPT="$SCRIPT_DIR/tm_tracker.sh"
if [[ ! -f "$TRACKER_SCRIPT" ]]; then
    echo "❌ Error: tm_tracker.sh not found at $TRACKER_SCRIPT"
    exit 1
fi

echo "🚀 Starting tracker in watch mode (5-second interval)..."
echo "   The tracker will monitor for changes and add timestamps automatically."
echo "   Press Ctrl+C to stop the demo."
echo ""

# Run the tracker in watch mode
"$TRACKER_SCRIPT" --watch --interval 5
