Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ps1 cmd git disc no libs3 #9

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions vendor/bin/cexec.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@echo off
setlocal

if "%~1" equ "" goto :wrongSyntax

Expand All @@ -7,7 +8,6 @@ if not defined CMDER_USER_FLAGS (
set "CMDER_USER_FLAGS= "
)


set "feNot=false"
goto :parseArgument

Expand All @@ -17,8 +17,10 @@ goto :parseArgument
:parseArgument
set "currenArgu=%~1"
if /i "%currenArgu%" equ "/setPath" (
set ccall=call "%~dp0cexec.cmd"
set cexec="%~dp0cexec.cmd"
:: set %flag_exists% shortcut
endlocal
set "ccall=call ^"%~dp0cexec.cmd^""
set "cexec=^"%~dp0cexec.cmd^""
) else if /i "%currenArgu%" == "/?" (
goto :help
) else if /i "%currenArgu%" equ "/help" (
Expand Down
25 changes: 25 additions & 0 deletions vendor/bin/cmder_debug_print.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@echo off

:debug_output
:::===============================================================================
:::debug_output - Output a debug message to the console.
:::.
:::include:
:::.
::: call "lib_console.cmd"
:::.
:::usage:
:::.
::: %lib_console% debug_output [caller] [message]
:::.
:::required:
:::.
::: [caller] <in> Script/sub routine name calling debug_output
:::.
::: [message] <in> Message text to display.
:::.
:::-------------------------------------------------------------------------------

REM if %debug_output% gtr 0 echo DEBUG(%~1): %~2 & echo.
echo DEBUG(%~1): %~2 & echo.
exit /b
111 changes: 111 additions & 0 deletions vendor/bin/cmder_enhance_path.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
@echo off

:enhance_path
:::===============================================================================
:::enhance_path - Add a directory to the path env variable if required.
:::
:::usage:
:::
::: call cmder_enhance_path "[dir_path]" [append]
:::
:::required:
:::
::: [dir_path] <in> Fully qualified directory path. Ex: "c:\bin"
:::
:::options:
:::
::: append <in> Append to the path env variable rather than pre-pend.
:::
:::
:::output:
:::
::: path <out> Sets the path env variable if required.
:::-------------------------------------------------------------------------------

if "%~1" neq "" (
set "add_path=%~1"
) else (
%error_print% "You must specify a directory to add to the path!"
exit 1
)

if "%~2" neq "" if /i "%~2" == "append" (
set "position=%~2"
) else (
set "position="
)

dir "%add_path%" | findstr -i "\.COM \.EXE \.BAT \.CMD \.PS1 \.VBS" >NUL
if "%ERRORLEVEL%" == "0" (
set "add_to_path=%add_path%"
) else (
set "add_to_path="
)

if "%fast_init%" == "1" (
if "%position%" == "append" (
set "PATH=%PATH%;%add_to_path%"
) else (
set "PATH=%add_to_path%;%PATH%"
)
goto :end_enhance_path
) else if "add_to_path" equ "" (
exit /b
)

set found=0
set "find_query=%add_to_path%"
set "find_query=%find_query:\=\\%"
set "find_query=%find_query: =\ %"
set OLD_PATH=%PATH%

setlocal enabledelayedexpansion
if "%found%" == "0" (
echo "%path%"|%WINDIR%\System32\findstr >nul /I /R /C:";%find_query%;"
call :set_found
)
%debug_print% :enhance_path "Env Var INSIDE PATH %find_query% - found=%found%"

if /i "%position%" == "append" (
if "!found!" == "0" (
echo "%path%"|%WINDIR%\System32\findstr >nul /I /R /C:";%find_query%\"$"
call :set_found
)
%debug_print% :enhance_path "Env Var END PATH %find_query% - found=!found!"
) else (
if "!found!" == "0" (
echo "%path%"|%WINDIR%\System32\findstr >nul /I /R /C:"^\"%find_query%;"
call :set_found
)
%debug_print% :enhance_path "Env Var BEGIN PATH %find_query% - found=!found!"
)
endlocal & set found=%found%

if "%found%" == "0" (
if /i "%position%" == "append" (
%debug_print% :enhance_path "Appending '%add_to_path%'"
set "PATH=%PATH%;%add_to_path%"
) else (
%debug_print% :enhance_path "Prepending '%add_to_path%'"
set "PATH=%add_to_path%;%PATH%"
)

set found=1
)

:end_enhance_path
set "PATH=%PATH:;;=;%"
if NOT "%OLD_PATH%" == "%PATH%" (
%debug_print% :enhance_path "END Env Var - PATH=%path%"
%debug_print% :enhance_path "Env Var %find_query% - found=%found%"
)
set "position="
set "add_to_path="
exit /b

:set_found
if "%ERRORLEVEL%" == "0" (
set found=1
)

exit /b
110 changes: 110 additions & 0 deletions vendor/bin/cmder_enhance_path_recursive.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
@echo off


:enhance_path_recursive
:::===============================================================================
:::enhance_path_recursive - Add a directory and subs to the path env variable if
::: required.
:::.
:::include:
:::.
::: call "$0"
:::.
:::usage:
:::.
::: call "%~DP0lib_path" enhance_path_recursive "[dir_path]" [max_depth] [append]
:::.
:::required:
:::.
::: [dir_path] <in> Fully qualified directory path. Ex: "c:\bin"
:::.
:::options:
:::.
::: [max_depth] <in> Max recuse depth. Default: 1
:::.
::: append <in> Append instead to path env variable rather than pre-pend.
:::.
:::output:
:::.
::: path <out> Sets the path env variable if required.
:::-------------------------------------------------------------------------------
if "%~1" neq "" (
set "add_path=%~1"
) else (
%error_print% "You must specify a directory to add to the path!"
exit 1
)

set "depth=%~2"
set "max_depth=%~3"

if "%~4" neq "" if /i "%~4" == "append" (
set "position=%~4"
) else (
set "position="
)

dir "%add_path%" 2>NUL | findstr -i "\.COM \.EXE \.BAT \.CMD \.PS1 \.VBS" >NUL

if "%ERRORLEVEL%" == "0" (
set "add_to_path=%add_path%"
) else (
set "add_to_path="
)

if "%fast_init%" == "1" (
if "%add_to_path%" neq "" (
call cmder_enhance_path "%add_to_path%" %position%
)
)

set "PATH=%PATH:;;=;%"
if "%fast_init%" == "1" (
exit /b
)

%debug_print% :enhance_path_recursive "Env Var - add_path=%add_to_path%"
%debug_print% :enhance_path_recursive "Env Var - position=%position%"
%debug_print% :enhance_path_recursive "Env Var - depth=%depth%"
%debug_print% :enhance_path_recursive "Env Var - max_depth=%max_depth%"

if %max_depth% gtr %depth% (
if "%add_to_path%" neq "" (
%debug_print% :enhance_path_recursive "Adding parent directory - '%add_to_path%'"
call cmder_enhance_path "%add_to_path%" %position%
)
call :set_depth
call :loop_depth
)

set "PATH=%PATH%"

exit /b

: set_depth
set /a "depth=%depth%+1"
exit /b

:loop_depth
if %depth% == %max_depth% (
exit /b
)

for /d %%i in ("%add_path%\*") do (
%debug_print% :enhance_path_recursive "Env Var BEFORE - depth=%depth%"
%debug_print% :enhance_path_recursive "Found Subdirectory - '%%~fi'"
call cmder_enhance_path_recursive "%%~fi" %depth% %max_depth% %position%
%debug_print% :enhance_path_recursive "Env Var AFTER- depth=%depth%"
)
exit /b

:set_found
if "%ERRORLEVEL%" == "0" (
set found=1
)

exit /b

:debug_output
echo DEBUG(%~1): %~2 & echo.
exit /b
22 changes: 22 additions & 0 deletions vendor/bin/cmder_error_print.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@echo off

:show_error
:::===============================================================================
:::show_error - Output an error message to the console.
:::.
:::include:
:::.
::: call "$0"
:::.
:::usage:
:::.
::: %lib_console% show_error "[message]"
:::.
:::required:
:::.
::: [message] <in> Message text to display.
:::.
:::-------------------------------------------------------------------------------

echo ERROR: %~1
exit /b
38 changes: 38 additions & 0 deletions vendor/bin/cmder_git_compare_versions.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@echo off

:compare_versions
:::===============================================================================
:::compare_versions - Compare semantic versions return latest version.
:::.
:::usage:
:::.
::: call "%CMDERR_BIN%\cmder_git_compare_versions.cmd" [SCOPE1] [SCOPE2]
:::.
:::required:
:::.
::: [SCOPE1] <in> Example: USER
::: [SCOPE2] <in> Example: VENDOR
:::-------------------------------------------------------------------------------

:: 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.

%debug_print% Comparing:
%debug_print% %~1: %USER_MAJOR%.%USER_MINOR%.%USER_PATCH%.%USER_BUILD%
%debug_print% %~2: %VENDORED_MAJOR%.%VENDORED_MINOR%.%VENDORED_PATCH%.%VENDORED_BUILD%

setlocal enabledelayedexpansion
if !%~1_MAJOR! GTR !%~2_MAJOR! (endlocal & exit /b 1)
if !%~1_MAJOR! LSS !%~2_MAJOR! (endlocal & exit /b -1)

if !%~1_MINOR! GTR !%~2_MINOR! (endlocal & exit /b 1)
if !%~1_MINOR! LSS !%~2_MINOR! (endlocal & exit /b -1)

if !%~1_PATCH! GTR !%~2_PATCH! (endlocal & exit /b 1)
if !%~1_PATCH! LSS !%~2_PATCH! (endlocal & exit /b -1)

if !%~1_BUILD! GTR !%~2_BUILD! (endlocal & exit /b 1)
if !%~1_BUILD! LSS !%~2_BUILD! (endlocal & exit /b -1)

:: looks like we have the same versions.
endlocal & exit /b 0
15 changes: 15 additions & 0 deletions vendor/bin/cmder_git_for_windows_path_sub.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@echo off

setlocal enabledelayedexpansion
set search=%~1
set replace=%~2


echo %search% | findstr -i "git" >nul
if "%errorlevel%" == "1" exit /b

set path=!path:%search%=%replace%!
(endlocal
set "path=%path%")

exit /b
15 changes: 15 additions & 0 deletions vendor/bin/cmder_git_get_user_git_version.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@echo off

:::===============================================================================
:::get_user_git_version - get the version information for the user provided git binary
:::.
:::usage:
:::.
::: call "%CMDERR_BIN%\cmder_git_get_user_git_version.cmd"
:::-------------------------------------------------------------------------------

:get_user_git_version
:: get the version information for the user provided git binary
call "%CMDERR_BIN%\cmder_git_read_version.cmd" USER "%test_dir%"
call "%CMDERR_BIN%\cmder_git_validate_version.cmd" USER %GIT_VERSION_USER%
exit /b
Loading