Skip to content

Commit

Permalink
perf: 优化代码结构
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerWordTree committed Oct 10, 2024
1 parent b21b3ae commit a5955d3
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions WinEnv.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ FOR %%A IN (%@%) DO (
CALL SET "_KEY=%%~A" & CALL CALL SET "_VALUE=%%_CONFIG.REPLACE.%%~A%%"
CALL ECHO %%_KEY%%=%%_VALUE%%
CALL Process.Callback.CMD IF /I "%%_VALUE%%" == "(Removed)" SET "_VALUE="
CALL Environment.Set.CMD "%%_CONFIG.SCOPE%%" "%%_KEY%%" "%%_VALUE%%"
CALL :SETENV
)
CALL Map.List.CMD "_CONFIG.INSERT"
FOR %%A IN (%@%) DO (
Expand All @@ -287,7 +287,7 @@ FOR %%A IN (%@%) DO (
CALL Environment.Get.CMD "%%_CONFIG.SCOPE%%" "%%_KEY%%"
CALL SET "_VALUE=%%_VALUE%%%%@%%"
CALL ECHO %%_KEY%%=%%_VALUE%%
CALL Environment.Set.CMD "%%_CONFIG.SCOPE%%" "%%_KEY%%" "%%_VALUE%%"
CALL :SETENV
)
CALL Map.List.CMD "_CONFIG.APPEND"
FOR %%A IN (%@%) DO (
Expand All @@ -296,10 +296,28 @@ FOR %%A IN (%@%) DO (
CALL Environment.Get.CMD "%%_CONFIG.SCOPE%%" "%%_KEY%%"
CALL SET "_VALUE=%%@%%%%_VALUE%%"
CALL ECHO %%_KEY%%=%%_VALUE%%
CALL Environment.Set.CMD "%%_CONFIG.SCOPE%%" "%%_KEY%%" "%%_VALUE%%"
CALL :SETENV
)
GOTO :EOF

::临时设置变量
::@Variables
:: *@, _CONFIG, _KEY, _VALUE
::@Arguments
:: %_CONFIG%: 配置实例
:: %_KEY%: 键
:: %_VALUE%: 值
::@Outputs
:: %%_KEY%%: 符合条件时, %_KEY%为键, %_VALUE%为值, 设置变量.
:SETENV
CALL Environment.Set.CMD "%%_CONFIG.SCOPE%%" "%%_KEY%%" "%%_VALUE%%"
IF "%_KEY%" == "" GOTO :EOF
IF /I "%_KEY%" == "PATH" GOTO :EOF
IF "%_KEY:~,1%" == "_" GOTO :EOF
IF "%_KEY:~,1%" == "@" GOTO :EOF
SET "%_KEY%=%_VALUE%"
GOTO :EOF

::输出高亮文本
::@Arguments
:: %*: 文本
Expand Down

0 comments on commit a5955d3

Please sign in to comment.