@ECHO OFF
setlocal enabledelayedexpansion

set argC=0
for %%x in (%*) do Set /A argC+=1
IF "%argC%" == "0" (
   echo Error: Argument missing. use '-h' for help.
   goto end
)

set sdk_path=%~dp0
IF EXIST "%sdk_path%" (
	set em_path=!sdk_path!
) ELSE (
	set em_path=.
)

set current_path=%CD%\em-cli.jar


for /F "usebackq tokens=1,2* delims=: " %%V in (`mode con`) do (
    if .%%V==.Columns (
        set COLUMNS=%%W
        goto done
    )
)

:done

IF EXIST "%current_path%" (
	java -jar "%current_path%" %*
) ELSE (
	java -jar "%em_path%\em-cli.jar" %*
)

:end
