#!/bin/bash
# Start soleprint with Docker (for network access to other services)
#
# Usage:
#   ./start.sh              # Start in foreground
#   ./start.sh -d           # Start detached
#   ./start.sh --build      # Rebuild image first

set -e
cd "$(dirname "$0")/.."

# Ensure gen/ exists
if [ ! -d "gen" ]; then
    echo "gen/ not found. Run ./ctrl/build.sh first"
    exit 1
fi

cd gen

ARGS=""
for arg in "$@"; do
    case $arg in
        -d|--detach) ARGS="$ARGS -d" ;;
        --build) ARGS="$ARGS --build" ;;
    esac
done

docker compose up $ARGS
