#!/bin/bash

CMD_1=$1
CMD_2=$2

CLIENT_PATH=/mnt/c/Users/144311/OneDrive\ -\ Arrow\ Electronics,\ Inc/key/client
MAN_PATH=/mnt/c/Users/144311/OneDrive\ -\ Arrow\ Electronics,\ Inc/key/manufacturer

CLIENT_PATH_TOGO=$CLIENT_PATH/$CMD_2
MAN_PATH_TOGO=$MAN_PATH/$CMD_2

print_dir ()
{
	for d in */ ; do #Cheking the directroy to print files
		if [ "$d" != "csl/" ];then #Exept csl/
			echo -e "  |--> $d"
		fi
	done
}

goto_client ()
{
	if [ -z "$CMD_2" ] 
	then
		cd "$CLIENT_PATH"
		explorer.exe . &
		exit
	elif [ "$CMD_2" == "list" ] 
	then 
		cd "$CLIENT_PATH"
		echo Currently awailable Clients are : 
		print_dir
	 else 
		if [ -d "$CLIENT_PATH_TOGO" ] 
		then 
			cd "$CLIENT_PATH_TOGO"
			explorer.exe . &
			exit
		else 
			cd "$CLIENT_PATH"
			echo "Client not found"
			echo Currently awailable Clients are : 
			print_dir
		fi
	fi
}

goto_manufacturer ()
{
	if [ -z "$CMD_2" ] 
	then
		cd "$MAN_PATH"
		explorer.exe . &
	elif [ "$CMD_2" == "list" ] 
	then 
		cd "$MAN_PATH"
		echo Currently awailable Manufacturer are : 
		print_dir
	 else 
		if [ -d "$MAN_PATH_TOGO" ]
		then 
			cd "$MAN_PATH_TOGO"
			explorer.exe . &
			exit
		else 
			cd "$MAN_PATH"
			echo "Manufacturer not found"
			echo Currently awailable Manufacturer are : 
			print_dir
		fi
	fi
}

check_command ()
{
	if [ -z "$CMD_1" ] 
	then
		echo no argument was given
		exit
	elif [ "$CMD_1" == "cli" ] 
	then 
		goto_client
	elif [ "$CMD_1" == "man" ] 
	then
		goto_manufacturer
	else 
		echo Invalid command : $CMD_1
	fi	
}

check_command
exit
