@echo off
setlocal
cd /d "%~dp0"

java -jar "%~dp0bin\cpiview.jar" download --input "%~dp0input" --config "%~dp0config\api.json" --parallel 10
if errorlevel 1 goto :FAIL

java -jar "%~dp0bin\cpiview.jar" analyze --input "%~dp0input"
if errorlevel 1 goto :FAIL

java -jar "%~dp0bin\cpiview.jar" view --output "%~dp0output"
if errorlevel 1 goto :FAIL

echo.
echo COMPLETED.
pause
exit /b 0

:FAIL
echo.
echo FAILED (exit code %errorlevel%).
pause
exit /b 1