#!/bin/sh

if ! test $1; then
file=`zenity --file-selection --title="Select the file you want to open with gwhy"`;
else
file=$1
fi

if test $file; then
d=`dirname $file`
cd $d
fi

case $file in
  *.java)
	b=`basename $file .java`
	krakatoa $b.java || exit 1
	echo "krakatoa on $b.java done"
	jessie -locs $b.jloc -why-opt -split-user-conj $b.jc || exit 2
	echo "jessie done"
	make -f $b.makefile gui
	;;
  *.c)
	b=`basename $file .c`
	caduceus -why-opt -split-user-conj $b.c
	make -f $b.makefile gui
	;;
  *.jc)
	b=`basename $file .jc`
	jessie $b.jc || exit 1
	make -f $b.makefile gui
	;;
  *.mlw|*.why)
	b=`basename $file`
	gwhy-bin -split-user-conj $b
	;;
  ?*)
	echo "$file does not have file type extension recognized by gwhy"
	;;
  *)
	echo "gwhy needs the name of a file to inspect in order to run"
esac


