@ECHO OFF
SETLOCAL

IF NOT EXIST testOut\ mkdir testOut

SET PROG=tclsh ..\poApps.tcl
IF NOT "%1"=="" SET PROG=%1

SET OPT=--dirdiff --batch --nosaveonexit --config ConfigDir
SET DIR=testIn

SET SYNCDIR=testOut\_SyncDirTest

IF EXIST %SYNCDIR%\ DEL /S /Q %SYNCDIR%
mkdir %SYNCDIR%

ECHO %PROG% %OPT% %DIR%\Cawt1 %SYNCDIR% --sync
CALL %PROG% %OPT% %DIR%\Cawt1 %SYNCDIR% --sync
IF NOT "%ERRORLEVEL%"=="0" ECHO ErrorCode sync dirs: %ERRORLEVEL%

ECHO %PROG% %OPT% %DIR%\Cawt1 %SYNCDIR% --diff
CALL %PROG% %OPT% %DIR%\Cawt1 %SYNCDIR% --diff
IF NOT "%ERRORLEVEL%"=="0" ECHO ErrorCode diff dirs: %ERRORLEVEL%

ECHO Adding 1 file and deleting 1 file
ECHO ASDF > %SYNCDIR%\asdf.txt
DEL %SYNCDIR%\Readme.txt

ECHO %PROG% %OPT% %DIR%\Cawt1 %SYNCDIR% --diff
CALL %PROG% %OPT% %DIR%\Cawt1 %SYNCDIR% --diff
IF NOT "%ERRORLEVEL%"=="1" ECHO ErrorCode diff dirs: %ERRORLEVEL%

ECHO %PROG% %OPT% %DIR%\Cawt1 %SYNCDIR% --syncdelete
CALL %PROG% %OPT% %DIR%\Cawt1 %SYNCDIR% --syncdelete
IF NOT "%ERRORLEVEL%"=="0" ECHO ErrorCode syncdelete dirs: %ERRORLEVEL%

ECHO %PROG% %OPT% %DIR%\Cawt1 %SYNCDIR% --diff --verbose 
CALL %PROG% %OPT% %DIR%\Cawt1 %SYNCDIR% --diff --verbose 
IF NOT "%ERRORLEVEL%"=="0" ECHO ErrorCode diff dirs: %ERRORLEVEL%
