@echo off
if exist client_app_postgresql.bat goto start
echo Error!! This batch file can only be executed in its own folder.
goto error

:start
set myclasspath=".;../../classes;..\..\lib\*"

if not "%2"=="" goto help
if "%1"=="" goto help
set SUB_COMMAND=%1
if "%SUB_COMMAND%"=="compile" goto compile
REM if "%SUB_COMMAND%"=="setpervasyncclientproperties" goto run
if "%SUB_COMMAND%"=="sync" goto run
if "%SUB_COMMAND%"=="insert" goto run
if "%SUB_COMMAND%"=="delete" goto run
if "%SUB_COMMAND%"=="update" goto run
if "%SUB_COMMAND%"=="add_sync_table" goto run


:help

Echo 	Usage
Echo 	-----
Echo 	client_app_postgresql.bat {compile  
Echo 	    ^| sync ^| insert ^| delete ^| update ^| add_sync_table}
Echo.
set BATCH_ERROR=1
goto error

:compile
@echo on
javac -classpath %myclasspath% -d . ClientAppPostgresql.java
@echo off
if ERRORLEVEL 1 goto error
goto success

:run
@echo on
java -classpath %myclasspath% ClientAppPostgresql %1 
@echo off
if ERRORLEVEL 1 goto error
goto success

:error
set BATCH_ERROR=1
echo "Shell script completed with error."
goto done

:success
set BATCH_ERROR=0
echo "Shell script completed successfully."

:done
rem -- We're done!