set dotenv-load

ctr := "maple"
bin := "bash"

ls:
    just --list

up:
    docker compose -f compose.yaml up --remove-orphans

down:
    docker compose -f compose.yaml down -v --remove-orphans

build:
    docker compose -f compose.yaml build

run:
    docker compose -f compose.yaml run {{ctr}} {{bin}}

exec:
    docker compose -f compose.yaml exec {{ctr}} {{bin}}

dl trg:
    docker compose -f compose.yaml run \
        --remove-orphans \

link plist dir:
    python3 maple-py/link.py {{plist}} {{dir}}

sync args:
    s5cmd {{args}}

usb dst="/Volumes/MAPLE":
    COPYFILE_DISABLE=1 rsync -rtvh --delete --size-only --no-perms --no-owner --no-group --modify-window=2 maple-py/data/usb/Contents/ {{dst}}/Contents/
    COPYFILE_DISABLE=1 rsync -rtvh --delete --size-only --no-perms --no-owner --no-group --modify-window=2 --exclude='USBANLZ/' maple-py/data/usb/PIONEER/ {{dst}}/PIONEER/
    rm -f {{dst}}/PIONEER/rekordbox/RBFLTR.DAT

usb-pdb dst="/Volumes/MAPLE":
    @test -d {{dst}}/PIONEER/rekordbox || (echo "no rekordbox dir at {{dst}}/PIONEER"; exit 1)
    COPYFILE_DISABLE=1 cp maple-py/data/MAPLE/PIONEER/rekordbox/export.pdb {{dst}}/PIONEER/rekordbox/export.pdb

usb-reset dst="/Volumes/MAPLE":
    @test -d {{dst}} || (echo "USB not mounted at {{dst}}"; exit 1)
    rm -rf {{dst}}/Contents {{dst}}/PIONEER
    COPYFILE_DISABLE=1 rsync -rtvh --no-perms --no-owner --no-group --modify-window=2 maple-py/data/MAPLE/Contents/ {{dst}}/Contents/
    COPYFILE_DISABLE=1 rsync -rtvh --no-perms --no-owner --no-group --modify-window=2 maple-py/data/MAPLE/PIONEER/ {{dst}}/PIONEER/

# Build the maple AceMo export.pdb and sync it onto the Windows USB (drive F: by
# default) over rekordbox's export.pdb, so it can be tested on the player against
# the audio/USBANLZ already on the stick. Runs from WSL via powershell.exe.
usb-win dst="/mnt/f":
    cd maple-py && uv run python tools/build_acemo.py
    @test -d {{dst}}/PIONEER/rekordbox || (echo "no {{dst}}/PIONEER/rekordbox - is the USB mounted at {{dst}}?"; exit 1)
    rsync -tvh --no-perms --no-owner --no-group maple-py/captures/maple_acemo.pdb {{dst}}/PIONEER/rekordbox/export.pdb

maple-setup:
    bash ./etc/maple_setup.sh

maple trg:
    sldl -c ./etc/sldl-macos.yaml {{trg}}
