#!/bin/bash
# test.sh v0.1 by CL
# modified: RLa				         10 Juni 2016

echo "-------------------------------------------------------"
echo "---                                                 ---"
echo "---             TEST Script          	          ---"
echo "---                    v0.1 by CL                   ---"
echo "---                                                 ---"
echo "-------------------------------------------------------"


function set_vars()
{
	LIB_VCE=cl-lib.sh
}


function source_lib()
{
	if [ -f "$(pwd)/$LIB_VCE" ];then
		source $(pwd)/$LIB_VCE
	else
		echo -ne "\n!!! Sorry $LIB_VCE neither does exist in $(pwd)!!!\n" 
		echo -ne "\n\tPlease provide the library $LIB_VCE\n"
		exit 1
	fi
}

function collect_data()
{
	SCHOOL=$(get_school)
	AREA=$(get_area)
	ORG=$(get_org)
	TREE=$(get_tree)
}


function main()
{
	echo -ne "\nWas soll installiert werden?\n"
	OPTIONS="SCHOOL AREA ORG TREE"
	select opt in $OPTIONS;
	do
		if [ "$opt" = "SCHOOL" ]; then
			echo -ne "\nTest Function get_school"
			test_school
		elif [ "$opt" = "AREA" ]; then
			echo -ne "\nTest Function get_area"
			test_area
		elif [ "$opt" = "ORG" ]; then
			echo -ne "\nTest Function get_org"
			test_org
		elif [ "$opt" = "TREE" ]; then
			echo -ne "\nTest Function get_tree"
			test_tree
		else
			echo "Unknown option"
		fi
	done
}


function test_school()
{
	SCHOOL=$(get_school)
	echo -ne "\n$SCHOOL"
}

function test_area()
{
	AREA=$(get_area)
	echo -ne "\n$AREA"
}

function test_org()
{
	ORG=$(get_org)
	echo -ne "\n$ORG"
}

function test_tree()
{
	TREE=$(get_tree)
	echo -ne "\n$TREE"
}


set_vars
source_lib
main
