#!/bin/bash

function usage()
{
	echo "-c for clear *.class, *.java~"
	echo "-f for compile without Warnings"
	echo "-w for compile with Warnings"
	echo "-a for -c -w -d"
	echo "-d to generate the HTML documentation"
	echo "-h for help"
	
	exit 1
}

function compile()
{
	clear
	javac $1 controller/*.java gui/*.java
}

function doc()
{
	javadoc controller/*.java gui/*.java -d doc
}

function clean()
{
	clear
	rm -f ./gui/*.class ./controller/*.class
	rm -f ./gui/*.java~ ./controller/*.java~
}

if [ $# == "0" ];then
	compile
fi
while [ "$#" -gt "0" ]; do
   case $1 in
      -f)
					shift 1
					compile
          ;;
      -w)
					shift 1
					compile -deprecation
          ;;
      -c)
    					shift 1
        				clean
          ;;
      -d)
        				shift 1
					doc
					;;
      -a)
					shift 1
					clean
					compile -deprecation
					doc
          ;;
					
      -h)
        				shift 1
					usage
					;;					
      *)  #echo "Unerwartete Option $1"
          usage
          ;;
   esac
done
