-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.cmd
More file actions
74 lines (62 loc) · 2.89 KB
/
Copy pathinstall.cmd
File metadata and controls
74 lines (62 loc) · 2.89 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
64
65
66
67
68
69
70
71
72
73
74
@echo off
setlocal
rem install.cmd -- enable `git word` on Windows via a global git alias.
rem
rem install.cmd auto: Python (full) if present, else Perl (consumer)
rem install.cmd --python force the Python build (mint / resolve / --vibe)
rem install.cmd --perl force the Perl consumer build (resolve + pass-through)
rem install.cmd --sep[=_] git word mints dashed (or _) by default (git config)
rem install.cmd --uninstall remove the `git word` alias
rem
rem Uses a git ALIAS rather than a PATH entry: a "!"-alias runs through Git's
rem bundled sh, which is the reliable way to hook a script-based subcommand on
rem Windows (no .exe wrapper or PATHEXT/shebang games). An explicit COMMITWORD_LLM_*
rem env var, or `git config --global commitword.llm.*`, configures --vibe.
rem This repo's directory: forward-slashed for Git's sh, trailing slash trimmed.
set "REPO=%~dp0"
set "REPO=%REPO:\=/%"
if "%REPO:~-1%"=="/" set "REPO=%REPO:~0,-1%"
where git >nul 2>nul || (echo install.cmd: git is not on PATH & exit /b 1)
set "MODE=auto"
set "SEP="
set "UNINSTALL="
:parse
if "%~1"=="" goto parsed
if /I "%~1"=="--python" (set "MODE=python" & shift & goto parse)
if /I "%~1"=="--perl" (set "MODE=perl" & shift & goto parse)
if /I "%~1"=="--uninstall" (set "UNINSTALL=1" & shift & goto parse)
if /I "%~1"=="--sep" (set "SEP=-" & shift & goto parse)
if /I "%~1"=="--sep=-" (set "SEP=-" & shift & goto parse)
if /I "%~1"=="--sep=_" (set "SEP=_" & shift & goto parse)
echo install.cmd: unknown option %~1 & exit /b 1
:parsed
if defined UNINSTALL goto uninstall
if "%MODE%"=="auto" ( where python >nul 2>nul && set "MODE=python" )
if "%MODE%"=="auto" ( where perl >nul 2>nul && set "MODE=perl" )
if "%MODE%"=="auto" (
echo install.cmd: neither python nor perl found on PATH ^(Git for Windows bundles Perl^).
exit /b 1
)
if "%MODE%"=="python" ( where python >nul 2>nul || (echo install.cmd: python not on PATH & exit /b 1) )
if "%MODE%"=="perl" ( where perl >nul 2>nul || (echo install.cmd: perl not on PATH & exit /b 1) )
if "%MODE%"=="python" (
set "CMD=!python '%REPO%/git-word'"
set "CAP=full: mint / resolve / --vibe"
) else (
set "CMD=!perl '%REPO%/git-word.pl'"
set "CAP=consumer: resolve + pass-through, no mint"
)
git config --global alias.word "%CMD%" || (echo install.cmd: failed to set git alias & exit /b 1)
echo installed: git word -^> %CMD%
echo backend: %MODE% [%CAP%]
if defined SEP (
git config --global commitword.sep "%SEP%"
echo config: commitword.sep = %SEP% ^(git word mints with this separator^)
if not "%MODE%"=="python" echo note: separators only affect minting; the %MODE% build doesn't mint
)
echo try: git word HEAD and git word ^<commitword^>
exit /b 0
:uninstall
git config --global --unset alias.word 2>nul
echo removed: git alias "word"
exit /b 0