path:
/zoop.cmd
2.24 KB | plain
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
75
76
77
78
79
80
@echo off
goto :main
:print_usage
echo Usage: zoop ^<command^> [^<pkg^>]
echo Available commands are listed below.
echo.
echo cat Show content of specified manifest.
echo list List installed apps
echo search Search available apps
goto :eof
:zoop_search
setlocal EnableDelayedExpansion
for /f "usebackq" %%i in (`dir /B /A:D "%SCOOP%\buckets\*" 2^>nul`) do (
for /f "usebackq" %%j in (`dir /B /A:-D "%SCOOP%\buckets\%%i\bucket\*%~1*.json" 2^>nul`) do (
echo %%~nj
)
)
endlocal DisableDelayedExpansion
goto :eof
:zoop_cat
setlocal
for /d %%d in ("%SCOOP%\buckets\*") do (
if exist "%%d\bucket\%~1.json" (
type "%%d\bucket\%~1.json"
exit /b 0
)
)
endlocal
goto :eof
:zoop_list
setlocal EnableDelayedExpansion
rem for /f "usebackq" %%i in (`dir /B /A:D "%SCOOP%\apps\*" 2^>nul`) do (
for /d %%i in ("%SCOOP%\apps\*") do (
rem for /f "usebackq skip=5 tokens=5 delims=[] " %%j in (`dir /A:L "%%i" 2^>nul ^| findstr.exe "^<JUNCTION^>" 2^>nul`) do (
rem for /f "usebackq skip=5 tokens=5 delims=[] " %%j in (`dir /A:L "%%i" 2^>nul ^| findstr.exe /v " bytes" 2^>nul`) do (
for /f "usebackq skip=5 tokens=%1,%2 delims=\[] " %%j in (`dir /A:L "%%i\curren*" 2^>nul`) do (
echo %%j/%%k
rem rem set "jnk_path=%%j"
rem rem echo !jnk_path:\??\%SCOOP%\apps\=!
)
)
endlocal DisableDelayedExpansion
goto :eof
:main
setlocal EnableDelayedExpansion
set command=%~1
set args=%2
if "!command!"=="cat" (
call :zoop_cat !args!
) else if "!command!"=="search" (
call :zoop_search !args!
) else if "!command!"=="list" (
rem Count the backslashes in %SCOOP%
set /a "backslashes=-1"
for %%i in (%SCOOP:\= %) do set /a backslashes+=1
REM Token in zoop_list is '\[] '
REM 06-Mar-26 01:10 <JUNCTION> current [\??\C:\ProgramData\scoop\apps\vim\9.2.0]
REM ^1 ^2 ^3 ^4 ^5^6^7^8
set /a "app_index=8+!backslashes!"
set /a "version_index=!app_index!+1"
echo Count %SCOOP% !backslashes! !app_index! !version_index!
call :zoop_list !app_index! !version_index!
) else if "!command!"=="help" (
call :print_usage
exit /b 0
) else (
call :print_usage
exit /b 1
)
endlocal DisableDelayedExpansion
goto :eof
call :zoop_search %*