#!/bin/sh

cmd="$1"
shift

case "$cmd" in
  build) crystal.bin "$cmd" --link-flags "${CRYSTAL_LINK_FLAGS:-}" "$@";;
  eval)
    TEMP=$(mktemp)
    if test $# -gt 0; then
      echo "$@" > "$TEMP"
    else
      # stdin.... hm
      cat > "$TEMP"
    fi
    crystal.bin run --link-flags "${CRYSTAL_LINK_FLAGS:-}" "$TEMP"
    rm "$TEMP"
    ;;
  *) crystal.bin "$cmd" "$@";;
esac
