Search/run.bat
partisan 5b90a372a1
Some checks failed
Run Integration Tests / test (push) Failing after 1m43s
updated 'run.sh' and 'run.bat' so the process name is 'qgato'
2024-12-19 18:45:48 +01:00

86 lines
1.9 KiB
Batchfile
Executable file

@echo off
setlocal enabledelayedexpansion
rem Initialize variables
set SKIP_CONFIG=""
set PORT=""
set DOMAIN=""
set BUILD_MODE=false
set BUILD_OUTPUT=qgato.exe
rem Parse arguments
:parse_args
if "%~1"=="" goto end_parse
if "%~1"=="--port" (
set PORT=%~2
shift
shift
goto parse_args
)
if "%~1"=="--domain" (
set DOMAIN=%~2
shift
shift
goto parse_args
)
if "%~1"=="--skip-config-check" (
set SKIP_CONFIG=--skip-config-check
shift
goto parse_args
)
if "%~1"=="--build" (
set BUILD_MODE=true
shift
goto parse_args
)
echo Unknown argument: %~1
exit /b 1
:end_parse
rem Use the current directory where the script is executed
pushd %~dp0
rem Collect all .go files in the current directory excluding *_test.go
set GO_FILES=
for %%f in (*.go) do (
echo %%f | findstr "_test.go" >nul
if errorlevel 1 (
set GO_FILES=!GO_FILES! %%f
)
)
if "%BUILD_MODE%"=="true" (
rem Build mode
echo Building application...
go build -o "%BUILD_OUTPUT%" !GO_FILES!
if errorlevel 1 (
echo Build failed!
exit /b 1
)
echo Build successful! Output: %CD%\%BUILD_OUTPUT%
) else (
rem Check if the executable exists
if not exist "%BUILD_OUTPUT%" (
echo Executable not found. Building it first...
go build -o "%BUILD_OUTPUT%" !GO_FILES!
if errorlevel 1 (
echo Build failed! Unable to run the application.
exit /b 1
)
)
rem Construct the command
set CMD="%BUILD_OUTPUT% !SKIP_CONFIG!"
if not "%PORT%"=="" set CMD=!CMD! --port %PORT%
if not "%DOMAIN%"=="" set CMD=!CMD! --domain %DOMAIN%
rem Informative output
echo Starting application with command: !CMD!
rem Run the application
call !CMD!
)
rem Return to the original directory
popd