ECHO OFF
SET command=%*
SET is_prompt=["%*"]==[""]
SET node_path="C:\Program Files\Sisense\app\gateway-service\node.exe"

if exist "C:\Program Files\Sisense\app\NodeJS\v12.7.0" (
   SET node_path="C:\Program Files\Sisense\app\NodeJS\v12.7.0\node.exe"
) 
goto :main


:prompt_user_input
  ECHO " > Please specify command to run. For help use -h. To finish type: q."
  SET /p user_input=" > Enter command:

  SET command=%user_input%
  if "%command%" == "q" goto :eof

  call :run_script
  call :prompt_user_input
EXIT /b 0

:run_script
  %node_path% "%~dp0/installer/index.js" %command%
EXIT /b 0

:main
  IF %is_prompt% (
    call :prompt_user_input 
  ) ELSE (
   call :run_script
  )

pause
goto :eof
