-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.bat
More file actions
132 lines (108 loc) · 3.52 KB
/
Copy pathstart.bat
File metadata and controls
132 lines (108 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
@echo off
setlocal enabledelayedexpansion
:: Read environment variables from .env file
call :loadEnvVar "HTTP_PROXY"
call :loadEnvVar "HTTPS_PROXY"
call :loadEnvVar "USE_NATIVE_TLS" "UV_NATIVE_TLS"
cd /d "%~dp0"
echo Starting Act-AIO...
echo Current directory: %CD%
echo.
call :showEnvVariables
echo.
echo Running Act-AIO...
uv run python -m act_aio.main
echo.
echo Act-AIO has finished.
pause
:loadEnvVar
:: Function to load environment variable from .env file
:: Usage: call :loadEnvVar "KEY_NAME" [VARIABLE_NAME]
:: If VARIABLE_NAME is provided, sets that variable instead of KEY_NAME
setlocal enabledelayedexpansion
set "search_key=%~1"
set "var_name=%~2"
if "%var_name%"=="" set "var_name=%~1"
set "found_value="
:: Check if .env file exists
if not exist ".env" (
goto :endLoadEnvVar
)
:: Read the .env file line by line
for /f "usebackq tokens=* delims=" %%i in (".env") do (
set "line=%%i"
:: Skip empty lines
if not "!line!"=="" (
:: Skip comments (lines starting with #)
set "first_char=!line:~0,1!"
if not "!first_char!"=="#" (
:: Look for = sign
for /f "tokens=1,* delims==" %%a in ("!line!") do (
set "current_key=%%a"
set "current_value=%%b"
:: Remove leading and trailing spaces from key
for /f "tokens=* delims= " %%x in ("!current_key!") do set "current_key=%%x"
if "!current_key!"=="!search_key!" (
:: Remove leading spaces from value if any
if defined current_value (
for /f "tokens=* delims= " %%y in ("!current_value!") do set "found_value=%%y"
) else (
set "found_value="
)
goto :endLoadEnvVar
)
)
)
)
)
:endLoadEnvVar
endlocal & set "%var_name%=%found_value%"
goto :eof
:showEnvVariables
:: Function to display all environment variables loaded from .env
setlocal enabledelayedexpansion
set "count=0"
echo Environment variables loaded from .env:
echo =======================================
:: Check if .env file exists
if not exist ".env" (
echo ^(no .env file found^)
goto :endShowEnvVariables
)
:: Read the .env file line by line and display each key=value pair
for /f "usebackq tokens=* delims=" %%i in (".env") do (
set "line=%%i"
:: Skip empty lines
if not "!line!"=="" (
:: Skip comments (lines starting with #)
set "first_char=!line:~0,1!"
if not "!first_char!"=="#" (
:: Look for = sign
for /f "tokens=1,* delims==" %%a in ("!line!") do (
set "current_key=%%a"
set "current_value=%%b"
:: Remove leading and trailing spaces from key
for /f "tokens=* delims= " %%x in ("!current_key!") do set "current_key=%%x"
:: Remove leading spaces from value if any
if defined current_value (
for /f "tokens=* delims= " %%y in ("!current_value!") do set "current_value=%%y"
) else (
set "current_value="
)
:: Increment counter
set /a count+=1
:: Display the key=value pair
echo [!count!] !current_key!=!current_value!
)
)
)
)
if !count! equ 0 (
echo ^(no valid environment variables found^)
) else (
echo ^(loaded !count! environment variables^)
)
:endShowEnvVariables
goto :eof
:end
pause