#!/bin/bash

CMD_1=$1
CMD_2=$2

OUTLOOK_EXE="/mnt/c/Program Files/Microsoft Office/root/Office16/OUTLOOK.EXE"
OULOOK_CMD="/select"
INBOX="outlook"
CALENDAR="calendar"

TO_OPEN=""
TO_EXE=""

CMD_CLIENT="cli"
CMD_MAN="man"
CMD_INBOX="inbox"
CMD_SENT="sent"

OTLK_CLINENT="Kunden" 
OTLK_MAN="Hersteller" 
OTLK_INBOX="Posteingang" 
OTLK_SENT="Gesendete Elemente"

goto_folder ()
{
	exec "$OUTLOOK_EXE" $OULOOK_CMD $INBOX:$TO_OPEN &
	exit
}

goto_calendar ()
{
	exec "$OUTLOOK_EXE" $OULOOK_CMD $INBOX:$CALENDAR &
	exit
}

command_translator ()
{
	if [ "$CMD_1" == "$CMD_CLIENT" ]
	then
		TO_OPEN=$OTLK_CLINENT
	elif [ "$CMD_1" == "$CMD_MAN" ]
	then
		TO_OPEN=$OTLK_MAN
	elif [ "$CMD_1" == "$CMD_INBOX" ]
	then
		TO_OPEN=$OTLK_INBOX
	elif [ "$CMD_1" == "$CMD_SENT" ]
	then
		TO_OPEN=$OTLK_SENT
	else 
		echo Invalid command : $CMD_1
	fi	
}

check_command ()
{
	if [ -z "$CMD_1" ] 
	then
		echo no argument was given
		exit
	elif [ "$CMD_1" == "cal" ]
	then 
		goto_calendar
 	else 
		if [ -z "$CMD_2" ] 
		then
			command_translator
			goto_folder
		else 
			command_translator
			TO_OPEN=$TO_OPEN/$CMD_2
			goto_folder
		fi	
	fi	
	exit
}

check_command
