-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_Check_Dependencies.bat
102 lines (94 loc) · 2.74 KB
/
_Check_Dependencies.bat
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
::=============================================================::
:: DEVELOPED 2013, REVISED 2013, Jeff Rimko. ::
::=============================================================::
::=============================================================::
:: SECTION: Environment Setup ::
::=============================================================::
@set TITLE=%~n0 "%~dp0"
@cd /d %~dp0 && echo off && title %TITLE%
::=============================================================::
:: SECTION: Main Body ::
::=============================================================::
:: Check for Python.
call:ChkDep^
"Python"^
"Python language interpreter."^
"www.python.org"^
"2.7/3.x"^
python -V
call:ChkDep^
"Qprompt"^
"Python library for quick CLI user prompts, input, and menus."^
"github.com/jeffrimko/Qprompt"^
"latest"^
python -c "import qprompt"
pause
exit /b 0
::=============================================================::
:: SECTION: Function Definitions ::
::=============================================================::
::-------------------------------------------------------------::
:: Checks if a dependency is available.
::
:: **Params**:
:: - 1 - Name of dependency.
:: - 2 - Description of dependency.
:: - 3 - Reference website or where to obtain info.
:: - 4 - Recommended version.
:: - 5+ - Non-blocking command to check if installed; usually version display
:: or help.
::
:: **Attention**:
:: Do not use quotes around the non-blocking command.
:: Quotes may be included in the remaining params if they are needed for the
:: non-blocking call.
::
:: **Preconditions**:
:: The global variable DEP_OK should be set to 1 before the first call to this
:: function.
::
:: **Postconditions**:
:: The global variable DEP_OK will be set to 0 if a dependency check fails.
:: This variable is not set back to 1 by this function, it may be explicitly
:: set outside the function
::
:: **Example**:
:: call::ChkDep^
:: "Utility"^
:: "Does something."^
:: "www.website.com"^
:: "1.2.3"^
:: utility -h
:: call::ChkDep^
:: "Utility"^
:: "Does something."^
:: "www.website.com"^
:: "1.2.3"^
:: utility -c "non-blocking cmd"
::-------------------------------------------------------------::
:ChkDep
echo Checking dependency for %~1...
shift
echo %~1
shift
echo Reference: %~1
shift
echo Recommended version: %~1
shift
echo --------
set CMD=%1
shift
:chkdep_shift_next
if [%1] neq [] (
set CMD=%CMD% %1
shift
goto:chkdep_shift_next
)
%CMD% > NUL 2>&1
if %ERRORLEVEL% neq 0 (
echo NOT FOUND!
set DEP_OK=0
goto:eof
)
echo OK.
goto:eof