This commit is contained in:
parent
72d76c85ed
commit
c8a5ae02c0
8 changed files with 511 additions and 21 deletions
41
run.bat
41
run.bat
|
@ -5,6 +5,8 @@ rem Initialize variables
|
|||
set SKIP_CONFIG=""
|
||||
set PORT=""
|
||||
set DOMAIN=""
|
||||
set BUILD_MODE=false
|
||||
set BUILD_OUTPUT=qgato.exe
|
||||
|
||||
rem Parse arguments
|
||||
:parse_args
|
||||
|
@ -26,6 +28,11 @@ if "%~1"=="--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
|
||||
|
||||
|
@ -34,22 +41,36 @@ exit /b 1
|
|||
rem Use the current directory where the script is executed
|
||||
pushd %~dp0
|
||||
|
||||
rem Collect all .go files in the current directory
|
||||
rem Collect all .go files in the current directory excluding *_test.go
|
||||
set GO_FILES=
|
||||
for %%f in (*.go) do (
|
||||
set GO_FILES=!GO_FILES! %%f
|
||||
echo %%f | findstr "_test.go" >nul
|
||||
if errorlevel 1 (
|
||||
set GO_FILES=!GO_FILES! %%f
|
||||
)
|
||||
)
|
||||
|
||||
rem Construct the command
|
||||
set CMD=go run !GO_FILES! !SKIP_CONFIG!
|
||||
if not "%PORT%"=="" set CMD=!CMD! --port %PORT%
|
||||
if not "%DOMAIN%"=="" set CMD=!CMD! --domain %DOMAIN%
|
||||
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 Construct the command
|
||||
set CMD=go run !GO_FILES! !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 Informative output
|
||||
echo Starting application with command: !CMD!
|
||||
|
||||
rem Run the Go program with the constructed command
|
||||
call !CMD!
|
||||
rem Run the Go program with the constructed command
|
||||
call !CMD!
|
||||
)
|
||||
|
||||
rem Return to the original directory
|
||||
popd
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue