# Pull track metadata from Subsonic into the local database
sync:
    cargo run --release -- sync

# Detect duplicate tracks using fuzzy and MBID matching (no network)
find:
    cargo run --release -- find

# Review duplicate pairs and pick canonical tracks (interactive, optional rating)
review:
    cargo run --release -- review

# Search tracks by title, artist, or album and print their IDs
search QUERY:
    cargo run --release -- search {{ QUERY }}

# Manually mark two tracks as duplicates (clears any prior decision)
link TRACK_A TRACK_B:
    cargo run --release -- link {{ TRACK_A }} {{ TRACK_B }}

# Show (and optionally decide) one duplicate group — pass TRACK=<id> to target a specific group
evaluate TRACK="":
    cargo run --release -- evaluate {{ TRACK }}

# Upload the Duplicates playlist to Subsonic
export:
    cargo run --release -- export

# Sync, find duplicates, then review — the main interactive workflow
run: sync find review

# Delete the local database (irreversible — all decisions will be lost)
clear-db:
    rm -f duplicates.db
    @echo "Database cleared."

# Run integration tests (requires podman)
test-integration:
    cargo test -p subsonic-duplicates-integration --features integration -- --nocapture
