-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai-commit.cmd
More file actions
executable file
·63 lines (54 loc) · 1.31 KB
/
ai-commit.cmd
File metadata and controls
executable file
·63 lines (54 loc) · 1.31 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
@echo off
setlocal enabledelayedexpansion
set "SCRIPT_DIR=%~dp0"
set "PS1_SCRIPT=%SCRIPT_DIR%ai-commit.ps1"
if "%~1"=="-h" goto :usage
if "%~1"=="--help" goto :usage
set "AMEND="
set "AGENT="
set "MAX_DIFF="
:parse_args
if "%~1"=="" goto :done_args
if "%~1"=="--amend" (
set "AMEND=1"
shift
goto :parse_args
)
if "%~1"=="-a" (
set "AGENT=%~2"
shift & shift
goto :parse_args
)
if "%~1"=="-m" (
set "MAX_DIFF=%~2"
shift & shift
goto :parse_args
)
echo Unknown option: %~1 >&2
goto :usage
:done_args
if not exist "%PS1_SCRIPT%" (
echo Error: %PS1_SCRIPT% not found. >&2
exit /b 1
)
set "POWERSHELL="
where pwsh >nul 2>&1 && set "POWERSHELL=pwsh" && goto :found_ps
where powershell >nul 2>&1 && set "POWERSHELL=powershell" && goto :found_ps
echo Error: PowerShell not found (tried pwsh, powershell). >&2
exit /b 1
:found_ps
set "ARGS=-ExecutionPolicy Bypass -File "%PS1_SCRIPT%""
if defined AMEND set "ARGS=!ARGS! -Amend"
if defined AGENT set "ARGS=!ARGS! -Agent "%AGENT%""
if defined MAX_DIFF set "ARGS=!ARGS! -MaxDiffLength %MAX_DIFF%"
%POWERSHELL% %ARGS%
exit /b %errorlevel%
:usage
echo Usage: %~nx0 [--amend] [-a AGENT] [-m MAX_DIFF_LENGTH] >&2
echo. >&2
echo Examples: >&2
echo %~nx0 >&2
echo %~nx0 --amend >&2
echo %~nx0 -a cursor-agent >&2
echo %~nx0 -m 8000 >&2
exit /b 1