#!/usr/bin/env zsh

if [[ -f "$1" ]]; then
  NAME="$(basename ${1%.m})"
  BINPATH="/tmp/$NAME"
  clang -fobjc-arc -framework Foundation "$1" -o "$BINPATH" && "$BINPATH"
elif [[ ! -z "$1" ]]; then
  echo "File not found: $1"
  exit 2
else
  echo "Usage: $(basename $0) <filename.m>"
  exit 1
fi
