#!/bin/sh
RUNDIR=".tapedeck"
if [ "$1" == "init" ]; then
    rm -rf "$RUNDIR"
fi
mkdir -p "$RUNDIR"

export RUST_LOG="DEBUG"
export TAPEDECK_DEV_DIR=`realpath "$RUNDIR"`

if [ "$1" == "init" ]; then
    exit 0
fi

if [ $# -eq 0 ]; then
    echo "Please provide args for 'cargo --bin' (e.g. tdplay, tdsearch)"
    exit 1
fi

cmd=$1
shift
cargo run --bin $cmd -- $@
