-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathversion.bat
More file actions
67 lines (53 loc) · 1.48 KB
/
version.bat
File metadata and controls
67 lines (53 loc) · 1.48 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
@echo off
SETLOCAL
set ver=v0.3.0
set toolFile=%~dp0tools
for /F "tokens=1,2 delims==" %%A in (%toolFile%) do (
set %%A=%%B
)
rem User forgot to specify the program or a flag
if "%1"=="" (
echo Usage: version ^<program^>
goto END
)
rem Display help
if "%1"=="-h" (
echo version displays the versions of programs you have installed.
echo.
echo Usage:
echo version ^<program^> display version of program
echo ^(if known and installed^)
echo version -h display this help
echo version -c display count of known programs
echo version -v display version of version
echo ^(yes, ^'version version^' also works!^)
goto END
)
rem Display recognized program count
if "%1"=="-c" (
set /a cnt=0
for /f %%a in ('type "%toolFile%"^|find "" /v /c') do set /a cnt=%%a
echo I know how to find the versions of %count% programs!
goto END
)
rem Display version of version
if "%1"=="-v" (
echo %ver%
goto END
)
rem User does not have that program installed
where %1 2>NUL >NUL
IF %ERRORLEVEL% NEQ 0 (
echo %1 does not seem to be installed
goto END
)
rem Display the version if we know about the tool
SETLOCAL ENABLEDELAYEDEXPANSION
set vers_arg=!tools_%1!
if "%vers_arg%"=="" (
echo I don't know how to find the version of ^'%1^'.
echo If you figure it out, let me know at https://github.com/bit101/version
) else (
call %1 !tools_%1!
)
:END