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}}

# Dump tracks from Spotify playlists (ids, urls, or spotify: uris)
spotify ids="7f5tPIfj21UJI4zfDmH4rx 6sAl8LhU6ediFNJRuQQIQX":
    cd maple-py && uv run src/spotify.py {{ids}} --csv

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/

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

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