mirror of
https://github.com/cmderdev/cmder.git
synced 2025-01-10 16:29:08 +08:00
make library comments consistent and clean up code
This commit is contained in:
parent
28f6098d48
commit
540532f126
64
vendor/lib/lib_base.cmd
vendored
64
vendor/lib/lib_base.cmd
vendored
@ -10,9 +10,8 @@ if "%~1" == "/h" (
|
|||||||
|
|
||||||
exit /b
|
exit /b
|
||||||
|
|
||||||
:help
|
|
||||||
:::===============================================================================
|
:::===============================================================================
|
||||||
:::show_subs - shows all sub routines in a .bat/.cmd file with documentation
|
:::help - shows all sub routines in a .bat/.cmd file with documentation
|
||||||
:::.
|
:::.
|
||||||
:::include:
|
:::include:
|
||||||
:::.
|
:::.
|
||||||
@ -20,16 +19,15 @@ exit /b
|
|||||||
:::.
|
:::.
|
||||||
:::usage:
|
:::usage:
|
||||||
:::.
|
:::.
|
||||||
::: %lib_base% show_subs "file"
|
::: %lib_base% help "file"
|
||||||
:::.
|
:::.
|
||||||
:::options:
|
:::options:
|
||||||
:::.
|
:::.
|
||||||
::: file <in> full path to file containing lib_routines to display
|
::: file <in> full path to file containing lib_routines to display
|
||||||
:::.
|
|
||||||
:::-------------------------------------------------------------------------------
|
:::-------------------------------------------------------------------------------
|
||||||
for /f "tokens=* delims=:" %%a in ('type "%~1" ^| %WINDIR%\System32\findstr /i /r "^:::"') do (
|
|
||||||
rem echo a="%%a"
|
|
||||||
|
|
||||||
|
:help
|
||||||
|
for /f "tokens=* delims=:" %%a in ('%WINDIR%\System32\findstr /i /r "^:::" "%~1"') do (
|
||||||
if "%%a"=="." (
|
if "%%a"=="." (
|
||||||
echo.
|
echo.
|
||||||
) else if /i "%%a" == "usage" (
|
) else if /i "%%a" == "usage" (
|
||||||
@ -44,9 +42,13 @@ exit /b
|
|||||||
pause
|
pause
|
||||||
exit /b
|
exit /b
|
||||||
|
|
||||||
:cmder_shell
|
|
||||||
:::===============================================================================
|
:::===============================================================================
|
||||||
:::show_subs - shows all sub routines in a .bat/.cmd file with documentation
|
:::cmder_shell - Initializes the Cmder shell environment variables
|
||||||
|
:::.
|
||||||
|
:::description:
|
||||||
|
:::.
|
||||||
|
::: This routine sets up the Cmder shell environment by detecting the
|
||||||
|
::: command shell and initializing related variables.
|
||||||
:::.
|
:::.
|
||||||
:::include:
|
:::include:
|
||||||
:::.
|
:::.
|
||||||
@ -55,15 +57,30 @@ exit /b
|
|||||||
:::usage:
|
:::usage:
|
||||||
:::.
|
:::.
|
||||||
::: %lib_base% cmder_shell
|
::: %lib_base% cmder_shell
|
||||||
:::.
|
|
||||||
:::options:
|
|
||||||
:::.
|
|
||||||
::: file <in> full path to file containing lib_routines to display
|
|
||||||
:::.
|
|
||||||
:::-------------------------------------------------------------------------------
|
:::-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
:cmder_shell
|
||||||
call :detect_comspec %ComSpec%
|
call :detect_comspec %ComSpec%
|
||||||
exit /b
|
exit /b
|
||||||
|
|
||||||
|
:::===============================================================================
|
||||||
|
:::detect_comspec - Detects the command shell being used:::
|
||||||
|
:::.
|
||||||
|
:::description:
|
||||||
|
:::.
|
||||||
|
::: This function sets the CMDER_SHELL variable to the name of the
|
||||||
|
::: detected command shell. It also initializes the CMDER_CLINK and
|
||||||
|
::: CMDER_ALIASES variables if they are not already defined.
|
||||||
|
:::.
|
||||||
|
:::include:
|
||||||
|
:::.
|
||||||
|
::: call "lib_base.cmd"
|
||||||
|
:::.
|
||||||
|
:::usage:
|
||||||
|
:::.
|
||||||
|
::: %lib_base% detect_comspec %ComSpec%
|
||||||
|
:::-------------------------------------------------------------------------------
|
||||||
|
|
||||||
:detect_comspec
|
:detect_comspec
|
||||||
set CMDER_SHELL=%~n1
|
set CMDER_SHELL=%~n1
|
||||||
if not defined CMDER_CLINK (
|
if not defined CMDER_CLINK (
|
||||||
@ -74,6 +91,27 @@ exit /b
|
|||||||
)
|
)
|
||||||
exit /b
|
exit /b
|
||||||
|
|
||||||
|
:::===============================================================================
|
||||||
|
:::update_legacy_aliases - Updates the legacy alias definitions in the user_aliases file
|
||||||
|
:::.
|
||||||
|
:::description:
|
||||||
|
:::.
|
||||||
|
::: This function checks if the user_aliases file contains the marker
|
||||||
|
::: ";= Add aliases below here". If the marker is not found, it creates
|
||||||
|
::: an initial user_aliases store by copying the default user_aliases file
|
||||||
|
::: from the CMDER_ROOT directory. If the CMDER_USER_CONFIG environment
|
||||||
|
::: variable is defined, it creates a backup of the existing user_aliases
|
||||||
|
::: file before copying the default file.
|
||||||
|
:::.
|
||||||
|
:::include:
|
||||||
|
:::.
|
||||||
|
::: call "lib_base.cmd"
|
||||||
|
:::.
|
||||||
|
:::usage:
|
||||||
|
:::.
|
||||||
|
::: %lib_base% update_legacy_aliases
|
||||||
|
:::-------------------------------------------------------------------------------
|
||||||
|
|
||||||
:update_legacy_aliases
|
:update_legacy_aliases
|
||||||
type "%user_aliases%" | %WINDIR%\System32\findstr /i ";= Add aliases below here" >nul
|
type "%user_aliases%" | %WINDIR%\System32\findstr /i ";= Add aliases below here" >nul
|
||||||
if "%errorlevel%" == "1" (
|
if "%errorlevel%" == "1" (
|
||||||
|
21
vendor/lib/lib_git.cmd
vendored
21
vendor/lib/lib_git.cmd
vendored
@ -12,7 +12,6 @@ if "%~1" == "/h" (
|
|||||||
|
|
||||||
exit /b
|
exit /b
|
||||||
|
|
||||||
:read_version
|
|
||||||
:::===============================================================================
|
:::===============================================================================
|
||||||
:::read_version - Get the git.exe version
|
:::read_version - Get the git.exe version
|
||||||
:::.
|
:::.
|
||||||
@ -34,6 +33,7 @@ exit /b
|
|||||||
::: GIT_VERSION_[GIT SCOPE] <out> Env variable containing Git semantic version string
|
::: GIT_VERSION_[GIT SCOPE] <out> Env variable containing Git semantic version string
|
||||||
:::-------------------------------------------------------------------------------
|
:::-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
:read_version
|
||||||
:: clear the variables
|
:: clear the variables
|
||||||
set GIT_VERSION_%~1=
|
set GIT_VERSION_%~1=
|
||||||
|
|
||||||
@ -64,7 +64,6 @@ exit /b
|
|||||||
|
|
||||||
exit /b
|
exit /b
|
||||||
|
|
||||||
:parse_version
|
|
||||||
:::===============================================================================
|
:::===============================================================================
|
||||||
:::parse_version - Parse semantic version string 'x.x.x.x' and return the pieces
|
:::parse_version - Parse semantic version string 'x.x.x.x' and return the pieces
|
||||||
:::.
|
:::.
|
||||||
@ -89,6 +88,7 @@ exit /b
|
|||||||
::: [SCOPE]_BUILD <out> Scoped Build version.
|
::: [SCOPE]_BUILD <out> Scoped Build version.
|
||||||
:::-------------------------------------------------------------------------------
|
:::-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
:parse_version
|
||||||
:: process a `x.x.x.xxxx.x` formatted string
|
:: process a `x.x.x.xxxx.x` formatted string
|
||||||
%print_debug% :parse_version "ARGV[1]=%~1, ARGV[2]=%~2"
|
%print_debug% :parse_version "ARGV[1]=%~1, ARGV[2]=%~2"
|
||||||
|
|
||||||
@ -111,9 +111,8 @@ exit /b
|
|||||||
|
|
||||||
:endlocal_set_git_version
|
:endlocal_set_git_version
|
||||||
|
|
||||||
:validate_version
|
|
||||||
:::===============================================================================
|
:::===============================================================================
|
||||||
:::validate_version - Validate semantic version string 'x.x.x.x'.
|
:::validate_version - Validate semantic version string 'x.x.x.x'
|
||||||
:::.
|
:::.
|
||||||
:::include:
|
:::include:
|
||||||
:::.
|
:::.
|
||||||
@ -129,6 +128,7 @@ exit /b
|
|||||||
::: [VERSION] <in> Semantic version String. Ex: 1.2.3.4
|
::: [VERSION] <in> Semantic version String. Ex: 1.2.3.4
|
||||||
:::-------------------------------------------------------------------------------
|
:::-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
:validate_version
|
||||||
:: now parse the version information into the corresponding variables
|
:: now parse the version information into the corresponding variables
|
||||||
%print_debug% :validate_version "ARGV[1]=%~1, ARGV[2]=%~2"
|
%print_debug% :validate_version "ARGV[1]=%~1, ARGV[2]=%~2"
|
||||||
|
|
||||||
@ -143,9 +143,8 @@ exit /b
|
|||||||
)
|
)
|
||||||
exit /b
|
exit /b
|
||||||
|
|
||||||
:compare_versions
|
|
||||||
:::===============================================================================
|
:::===============================================================================
|
||||||
:::compare_version - Compare semantic versions return latest version.
|
:::compare_version - Compare semantic versions and return latest version
|
||||||
:::.
|
:::.
|
||||||
:::include:
|
:::include:
|
||||||
:::.
|
:::.
|
||||||
@ -161,6 +160,7 @@ exit /b
|
|||||||
::: [SCOPE2] <in> Example: VENDOR
|
::: [SCOPE2] <in> Example: VENDOR
|
||||||
:::-------------------------------------------------------------------------------
|
:::-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
:compare_versions
|
||||||
:: checks all major, minor, patch and build variables for the given arguments.
|
:: checks all major, minor, patch and build variables for the given arguments.
|
||||||
:: whichever binary that has the most recent version will be used based on the return code.
|
:: whichever binary that has the most recent version will be used based on the return code.
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ exit /b
|
|||||||
endlocal & exit /b 0
|
endlocal & exit /b 0
|
||||||
|
|
||||||
:::===============================================================================
|
:::===============================================================================
|
||||||
:::is_git_shim
|
:::is_git_shim - Check if the directory has a git.shim file
|
||||||
:::.
|
:::.
|
||||||
:::include:
|
:::include:
|
||||||
:::.
|
:::.
|
||||||
@ -219,7 +219,7 @@ exit /b
|
|||||||
exit /b
|
exit /b
|
||||||
|
|
||||||
:::===============================================================================
|
:::===============================================================================
|
||||||
:::compare_git_versions
|
:::compare_git_versions - Compare the user git version against the vendored version
|
||||||
:::.
|
:::.
|
||||||
:::include:
|
:::include:
|
||||||
:::.
|
:::.
|
||||||
@ -262,7 +262,7 @@ exit /b
|
|||||||
exit /b
|
exit /b
|
||||||
|
|
||||||
:::===============================================================================
|
:::===============================================================================
|
||||||
:::get_user_git_version - get the version information for the user provided git binary
|
:::get_user_git_version - Get the version information for the user provided git binary
|
||||||
:::.
|
:::.
|
||||||
:::include:
|
:::include:
|
||||||
:::.
|
:::.
|
||||||
@ -278,5 +278,4 @@ exit /b
|
|||||||
%lib_git% read_version USER "%test_dir%" 2>nul
|
%lib_git% read_version USER "%test_dir%" 2>nul
|
||||||
%print_debug% ":get_user_git_version" "get_user_git_version GIT_VERSION_USER: %GIT_VERSION_USER%"
|
%print_debug% ":get_user_git_version" "get_user_git_version GIT_VERSION_USER: %GIT_VERSION_USER%"
|
||||||
%lib_git% validate_version USER %GIT_VERSION_USER%
|
%lib_git% validate_version USER %GIT_VERSION_USER%
|
||||||
exit /b
|
exit /b
|
||||||
|
|
||||||
|
19
vendor/lib/lib_profile.cmd
vendored
19
vendor/lib/lib_profile.cmd
vendored
@ -12,26 +12,26 @@ if "%~1" == "/h" (
|
|||||||
|
|
||||||
exit /b
|
exit /b
|
||||||
|
|
||||||
:run_profile_d
|
|
||||||
:::===============================================================================
|
:::===============================================================================
|
||||||
:::run_profile_d - Run all scripts in the passed dir path
|
:::run_profile_d - Run all scripts in the passed directory path
|
||||||
:::
|
:::.
|
||||||
:::include:
|
:::include:
|
||||||
:::
|
:::.
|
||||||
::: call "lib_profile.cmd"
|
::: call "lib_profile.cmd"
|
||||||
:::
|
:::.
|
||||||
:::usage:
|
:::usage:
|
||||||
:::
|
:::.
|
||||||
::: %lib_profile% "[dir_path]"
|
::: %lib_profile% "[dir_path]"
|
||||||
:::
|
:::.
|
||||||
:::required:
|
:::required:
|
||||||
:::
|
:::.
|
||||||
::: [dir_path] <in> Fully qualified directory path containing init *.cmd|*.bat.
|
::: [dir_path] <in> Fully qualified directory path containing init *.cmd|*.bat.
|
||||||
::: Example: "c:\bin"
|
::: Example: "c:\bin"
|
||||||
:::
|
:::.
|
||||||
::: path <out> Sets the path env variable if required.
|
::: path <out> Sets the path env variable if required.
|
||||||
:::-------------------------------------------------------------------------------
|
:::-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
:run_profile_d
|
||||||
if not exist "%~1" (
|
if not exist "%~1" (
|
||||||
mkdir "%~1"
|
mkdir "%~1"
|
||||||
)
|
)
|
||||||
@ -43,4 +43,3 @@ exit /b
|
|||||||
)
|
)
|
||||||
popd
|
popd
|
||||||
exit /b
|
exit /b
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user