#!/bin/bash

CMD_1=$1
CMD_2=$2
CMD_3=$3

ONENOTE_EXE="/mnt/c/Program Files/Microsoft Office/root/Office16/ONENOTE.EXE"
ONENOTE_CMD="/hyperlink"

index=1 

arr_cmds=("")
arr_links=("")


ONENOTE_DIR="onenote:https://arrowelectronics-my.sharepoint.com/personal/kerem_yollu_arrow_com/Documents"
ONENOTE_SUB_DIR=""
FILE_MEETING="Meetings"
FILE_TEAM="Team" 
FILE_CLI="Kunde" 
FILE_MAN="Manufacturer"

arr_cmds+=("todo")
arr_links+=("onenote:https://arrowelectronics-my.sharepoint.com/personal/kerem_yollu_arrow_com/Documents/Kerem%20@%20Work/Todo.one#DAILY&section-id={53FE035C-047E-4BB9-B2BD-A9AF0493259E}&page-id={62AAD6BE-8F22-4C56-AFB5-D4B75812E379}&end")

goto_folder ()
{
	for list in "${arr_cmds[@]}"
	do
		for item in $list
		do
			if [ "$item" == "$CMD_1" ]
			then
				echo Will open : ${arr_links[$index]}
				exec "$ONENOTE_EXE" $ONENOTE_CMD ${arr_links[$index]} &
			fi
			((index=index + 1))
		done
	done
	echo Comman not found : $CMD_1
}


goto_direct () 
{
	if [ "$CMD_1" == "cli" ] 
	then 
		ONENOTE_SUB_DIR=$FILE_CLI	
	elif [ "$CMD_1" == "man" ] 
	then
		ONENOTE_SUB_DIR=$FILE_MAN	
	elif [ "$CMD_1" == "meet" ] 
	then
		ONENOTE_SUB_DIR=$FILE_MEETING	
	else 
		echo Invalid command : $CMD_1
		exit
	fi	
	
	echo Will open : $ONENOTE_DIR/$ONENOTE_SUB_DIR/$CMD_2.one
	exec "$ONENOTE_EXE" $ONENOTE_CMD $ONENOTE_DIR/$ONENOTE_SUB_DIR/$CMD_2.one &
}

check_command ()
{
	if [ -z "$CMD_1" ] 
	then	
		echo no argument was given
		exit
	else
		if [ -z "$CMD_2" ] 
		then
			goto_folder
		else 
			goto_direct
		fi
	fi	
}

check_command
exit
