#!/bin/sh

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

case $file in
  *.java)
	b=`basename $file .java`
	krakatoa -gen-only $file || exit 1
	echo "krakatoa on $b.java done"
        d=`dirname $file`
        echo "cd $d"
        cd $d
	jessie -locs $b.jloc -why-opt -split-user-conj $b.jc || exit 2
	echo "jessie done"
	make -f $b.makefile gui
	;;
  *.c)
	frama-c -jessie -jessie-atp=gui -jessie-why-opt="-split-user-conj" $file || exit 1
	;;
  *.jc)
	b=`basename $file .jc`
	jessie -why-opt -split-user-conj $b.jc || exit 1
	make -f $b.makefile gui
	;;
  *.mlw|*.why)
	gwhy-bin -split-user-conj $file
	;;
  ?*)
	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


