#!/bin/bash

case "$1" in
    "start")
        mkdir -p media/screenshots
        chmod -R 777 media
        docker-compose up -d
        echo "Services started. Access:"
        echo "- Web: http://localhost:8000"
        docker-compose logs -f
        ;;
    "stop")
        docker-compose down
        ;;
    "restart")
        docker-compose restart
        ;;
    "logs")
        if [ "$2" ]; then
            docker-compose logs -f "$2"
        else
            docker-compose logs -f
        fi
        ;;
    "build")
        docker-compose build
        ;;
    "shell")
        docker-compose exec web bash
        ;;
    "static")
        docker-compose exec web uv run manage.py collectstatic
        ;;
    "migrate")
        docker-compose exec web uv run manage.py makemigrations
        docker-compose exec web uv run manage.py migrate
        ;;
    "tailwind-logs")
        docker-compose logs -f tailwind
        ;;
    "tailwind-build")
        docker-compose exec tailwind npm run build
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|logs|build|shell|migrate|static|tailwind-logs|tailwind-build}"
        echo ""
        echo "Additional commands:"
        echo "  logs [service]    View logs of all services or specific service"
        echo "  static           Collect static files"
        exit 1
        ;;
esac
