@echo off

:setup
setlocal EnableDelayedExpansion

set whiteList[1]=C:\virtual_drives\k\airnorth
set whiteList[2]=C:\virtual_drives\k\united
set whiteList[3]=C:\virtual_drives\m\users\ua-user
set whiteList[4]=C:\virtual_drives\m\users\4n-user\4n-suite\1.0
set whiteList[5]=C:\virtual_drives\u\ua
set whiteList[6]=C:\virtual_drives\z\qlo\users\ua
set whiteList[7]=C:\virtual_drives\common\Qlogic.Signal.Web.Sdk
set whiteList[8]=C:\virtual_drives\common\StationManager\4.7
set workingDir=%cd%
set relativePath=%cd:~3%

for /l %%i in (1,1,8) do (
    if /i "%workingDir%" equ "!whiteList[%%i]!" goto CheckCommandLine
)
set err="%workingDir%" not in whitelist.
goto Error

:CheckCommandLine
set argCount=0
for %%x in (%*) do (
   set /A argCount+=1
   set "argVec[!argCount!]=%%~x"
)
for /L %%i in (1,1,%argCount%) do (
    echo %%i- "!argVec[%%i]!"
    if %%i equ 1 set host=!argVec[%%i]!
    if /i "!argVec[%%i]:~0,2!" == "/m" set "mirrorArg= /mir"
    if /i "!argVec[%%i]:~0,2!" == "/l" set "listOnlyArg= /l"
    if /i "!argVec[%%i]:~0,8!" == "/dry-run" set "listOnlyArg= /l"
)
if [%host%] == [] (
    set err=Please provide host name.
    goto Error
)

:Run
robocopy /xo /e "%workingDir%" "\\%host%\%relativePath%"%listOnlyArg%%mirrorArg% /xd net6.0 net6.0-windows publish ref win-x64 win-x86
goto Cleanup

:Error
echo %err%

:Cleanup
endlocal