#!/usr/bin/env bash

set -euo pipefail

if [ ! -z "$MODULE" ]; then
    MODULE="-p $MODULE"
fi

if [ -z "${PARAMS-}" ]; then
    PARAMS=""
fi

case $CMD in
    build)
        $CARGO build $MODULE $PARAMS
        ;;
    test)
        $CARGO test $MODULE $PARAMS
        ;;
    release)
        $CARGO build --release $MODULE $PARAMS
        ;;
    clean)
        $CARGO clean $MODULE
        ;;
    "")
        echo "No command specified. Use build | test | release | clean"
        ;;
    *)
        echo "$CMD is unknown. Use build | test | release | clean"
        ;;
esac

