Skip to content

Commit 540532f

Browse files
committed
make library comments consistent and clean up code
1 parent 28f6098 commit 540532f

File tree

3 files changed

+69
-33
lines changed

3 files changed

+69
-33
lines changed

vendor/lib/lib_base.cmd

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,24 @@ if "%~1" == "/h" (
1010

1111
exit /b
1212

13-
:help
1413
:::===============================================================================
15-
:::show_subs - shows all sub routines in a .bat/.cmd file with documentation
14+
:::help - shows all sub routines in a .bat/.cmd file with documentation
1615
:::.
1716
:::include:
1817
:::.
1918
::: call "lib_base.cmd"
2019
:::.
2120
:::usage:
2221
:::.
23-
::: %lib_base% show_subs "file"
22+
::: %lib_base% help "file"
2423
:::.
2524
:::options:
2625
:::.
2726
::: file <in> full path to file containing lib_routines to display
28-
:::.
2927
:::-------------------------------------------------------------------------------
30-
for /f "tokens=* delims=:" %%a in ('type "%~1" ^| %WINDIR%\System32\findstr /i /r "^:::"') do (
31-
rem echo a="%%a"
3228

29+
:help
30+
for /f "tokens=* delims=:" %%a in ('%WINDIR%\System32\findstr /i /r "^:::" "%~1"') do (
3331
if "%%a"=="." (
3432
echo.
3533
) else if /i "%%a" == "usage" (
@@ -44,9 +42,13 @@ exit /b
4442
pause
4543
exit /b
4644

47-
:cmder_shell
4845
:::===============================================================================
49-
:::show_subs - shows all sub routines in a .bat/.cmd file with documentation
46+
:::cmder_shell - Initializes the Cmder shell environment variables
47+
:::.
48+
:::description:
49+
:::.
50+
::: This routine sets up the Cmder shell environment by detecting the
51+
::: command shell and initializing related variables.
5052
:::.
5153
:::include:
5254
:::.
@@ -55,14 +57,29 @@ exit /b
5557
:::usage:
5658
:::.
5759
::: %lib_base% cmder_shell
60+
:::-------------------------------------------------------------------------------
61+
62+
:cmder_shell
63+
call :detect_comspec %ComSpec%
64+
exit /b
65+
66+
:::===============================================================================
67+
:::detect_comspec - Detects the command shell being used:::
5868
:::.
59-
:::options:
69+
:::description:
6070
:::.
61-
::: file <in> full path to file containing lib_routines to display
71+
::: This function sets the CMDER_SHELL variable to the name of the
72+
::: detected command shell. It also initializes the CMDER_CLINK and
73+
::: CMDER_ALIASES variables if they are not already defined.
74+
:::.
75+
:::include:
6276
:::.
77+
::: call "lib_base.cmd"
78+
:::.
79+
:::usage:
80+
:::.
81+
::: %lib_base% detect_comspec %ComSpec%
6382
:::-------------------------------------------------------------------------------
64-
call :detect_comspec %ComSpec%
65-
exit /b
6683

6784
:detect_comspec
6885
set CMDER_SHELL=%~n1
@@ -74,6 +91,27 @@ exit /b
7491
)
7592
exit /b
7693

94+
:::===============================================================================
95+
:::update_legacy_aliases - Updates the legacy alias definitions in the user_aliases file
96+
:::.
97+
:::description:
98+
:::.
99+
::: This function checks if the user_aliases file contains the marker
100+
::: ";= Add aliases below here". If the marker is not found, it creates
101+
::: an initial user_aliases store by copying the default user_aliases file
102+
::: from the CMDER_ROOT directory. If the CMDER_USER_CONFIG environment
103+
::: variable is defined, it creates a backup of the existing user_aliases
104+
::: file before copying the default file.
105+
:::.
106+
:::include:
107+
:::.
108+
::: call "lib_base.cmd"
109+
:::.
110+
:::usage:
111+
:::.
112+
::: %lib_base% update_legacy_aliases
113+
:::-------------------------------------------------------------------------------
114+
77115
:update_legacy_aliases
78116
type "%user_aliases%" | %WINDIR%\System32\findstr /i ";= Add aliases below here" >nul
79117
if "%errorlevel%" == "1" (

vendor/lib/lib_git.cmd

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ if "%~1" == "/h" (
1212

1313
exit /b
1414

15-
:read_version
1615
:::===============================================================================
1716
:::read_version - Get the git.exe version
1817
:::.
@@ -34,6 +33,7 @@ exit /b
3433
::: GIT_VERSION_[GIT SCOPE] <out> Env variable containing Git semantic version string
3534
:::-------------------------------------------------------------------------------
3635

36+
:read_version
3737
:: clear the variables
3838
set GIT_VERSION_%~1=
3939

@@ -64,7 +64,6 @@ exit /b
6464

6565
exit /b
6666

67-
:parse_version
6867
:::===============================================================================
6968
:::parse_version - Parse semantic version string 'x.x.x.x' and return the pieces
7069
:::.
@@ -89,6 +88,7 @@ exit /b
8988
::: [SCOPE]_BUILD <out> Scoped Build version.
9089
:::-------------------------------------------------------------------------------
9190

91+
:parse_version
9292
:: process a `x.x.x.xxxx.x` formatted string
9393
%print_debug% :parse_version "ARGV[1]=%~1, ARGV[2]=%~2"
9494

@@ -111,9 +111,8 @@ exit /b
111111

112112
:endlocal_set_git_version
113113

114-
:validate_version
115114
:::===============================================================================
116-
:::validate_version - Validate semantic version string 'x.x.x.x'.
115+
:::validate_version - Validate semantic version string 'x.x.x.x'
117116
:::.
118117
:::include:
119118
:::.
@@ -129,6 +128,7 @@ exit /b
129128
::: [VERSION] <in> Semantic version String. Ex: 1.2.3.4
130129
:::-------------------------------------------------------------------------------
131130

131+
:validate_version
132132
:: now parse the version information into the corresponding variables
133133
%print_debug% :validate_version "ARGV[1]=%~1, ARGV[2]=%~2"
134134

@@ -143,9 +143,8 @@ exit /b
143143
)
144144
exit /b
145145

146-
:compare_versions
147146
:::===============================================================================
148-
:::compare_version - Compare semantic versions return latest version.
147+
:::compare_version - Compare semantic versions and return latest version
149148
:::.
150149
:::include:
151150
:::.
@@ -161,6 +160,7 @@ exit /b
161160
::: [SCOPE2] <in> Example: VENDOR
162161
:::-------------------------------------------------------------------------------
163162

163+
:compare_versions
164164
:: checks all major, minor, patch and build variables for the given arguments.
165165
:: whichever binary that has the most recent version will be used based on the return code.
166166

@@ -185,7 +185,7 @@ exit /b
185185
endlocal & exit /b 0
186186

187187
:::===============================================================================
188-
:::is_git_shim
188+
:::is_git_shim - Check if the directory has a git.shim file
189189
:::.
190190
:::include:
191191
:::.
@@ -219,7 +219,7 @@ exit /b
219219
exit /b
220220

221221
:::===============================================================================
222-
:::compare_git_versions
222+
:::compare_git_versions - Compare the user git version against the vendored version
223223
:::.
224224
:::include:
225225
:::.
@@ -262,7 +262,7 @@ exit /b
262262
exit /b
263263

264264
:::===============================================================================
265-
:::get_user_git_version - get the version information for the user provided git binary
265+
:::get_user_git_version - Get the version information for the user provided git binary
266266
:::.
267267
:::include:
268268
:::.
@@ -278,5 +278,4 @@ exit /b
278278
%lib_git% read_version USER "%test_dir%" 2>nul
279279
%print_debug% ":get_user_git_version" "get_user_git_version GIT_VERSION_USER: %GIT_VERSION_USER%"
280280
%lib_git% validate_version USER %GIT_VERSION_USER%
281-
exit /b
282-
281+
exit /b

vendor/lib/lib_profile.cmd

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@ if "%~1" == "/h" (
1212

1313
exit /b
1414

15-
:run_profile_d
1615
:::===============================================================================
17-
:::run_profile_d - Run all scripts in the passed dir path
18-
:::
16+
:::run_profile_d - Run all scripts in the passed directory path
17+
:::.
1918
:::include:
20-
:::
19+
:::.
2120
::: call "lib_profile.cmd"
22-
:::
21+
:::.
2322
:::usage:
24-
:::
23+
:::.
2524
::: %lib_profile% "[dir_path]"
26-
:::
25+
:::.
2726
:::required:
28-
:::
27+
:::.
2928
::: [dir_path] <in> Fully qualified directory path containing init *.cmd|*.bat.
3029
::: Example: "c:\bin"
31-
:::
30+
:::.
3231
::: path <out> Sets the path env variable if required.
3332
:::-------------------------------------------------------------------------------
3433

34+
:run_profile_d
3535
if not exist "%~1" (
3636
mkdir "%~1"
3737
)
@@ -43,4 +43,3 @@ exit /b
4343
)
4444
popd
4545
exit /b
46-

0 commit comments

Comments
 (0)