#!/bin/bash
# ============================================
# BreakPilot Quick Start
# ============================================
# Usage: ./scripts/start.sh [dev|staging|prod] [services...]
#
# Examples:
#   ./scripts/start.sh dev                    # Start all dev services
#   ./scripts/start.sh dev backend postgres   # Start only specific services
#   ./scripts/start.sh staging                # Start staging environment
# ============================================

set -e

ENV=${1:-dev}
shift 2>/dev/null || true
SERVICES="$@"

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(dirname "$SCRIPT_DIR")"

# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'

cd "$ROOT_DIR"

# Switch environment
"$SCRIPT_DIR/env-switch.sh" "$ENV"

echo ""
echo -e "${YELLOW}Starting services...${NC}"
echo ""

case $ENV in
    dev|development)
        docker compose up -d $SERVICES
        ;;
    staging)
        docker compose -f docker-compose.yml -f docker-compose.staging.yml up -d $SERVICES
        ;;
    prod|production)
        docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d $SERVICES
        ;;
esac

echo ""
echo -e "${GREEN}✓ Services started!${NC}"
echo ""
echo "Check status with: docker compose ps"
echo "View logs with:    docker compose logs -f [service]"
