Search/run.bat

72 lines
1.5 KiB
Batchfile
Raw Permalink Normal View History

2024-08-13 16:31:28 +02:00
@echo off
setlocal enabledelayedexpansion
rem Initialize variables
set SKIP_CONFIG=""
set PORT=""
set DOMAIN=""
2024-12-05 00:24:47 +01:00
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
)
echo Unknown argument: %~1
exit /b 1
:end_parse
2024-10-22 21:58:06 +02:00
rem Use the current directory where the script is executed
pushd %~dp0
2024-08-13 16:31:28 +02:00
2024-12-05 00:24:47 +01:00
rem Collect all .go files in the current directory excluding *_test.go
2024-10-22 21:58:06 +02:00
set GO_FILES=
2024-08-13 16:31:28 +02:00
for %%f in (*.go) do (
2024-12-05 00:24:47 +01:00
echo %%f | findstr "_test.go" >nul
if errorlevel 1 (
set GO_FILES=!GO_FILES! %%f
)
2024-08-13 16:31:28 +02:00
)
2025-01-08 00:29:21 +01:00
rem Always delete and rebuild the binary
echo Cleaning previous build...
if exist "%BUILD_OUTPUT%" del "%BUILD_OUTPUT%"
2025-01-08 00:29:21 +01:00
echo Building application...
go build -o "%BUILD_OUTPUT%" !GO_FILES!
if errorlevel 1 (
echo Build failed!
exit /b 1
2024-12-05 00:24:47 +01:00
)
2025-01-08 00:29:21 +01:00
echo Build successful! Output: %CD%\%BUILD_OUTPUT%
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 built executable
call !CMD!
2024-08-13 16:31:28 +02:00
rem Return to the original directory
popd