-
Notifications
You must be signed in to change notification settings - Fork 0
/
choice.bat
59 lines (48 loc) · 1.08 KB
/
choice.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
@ECHO OFF
SETLOCAL
CALL :CHOICE "Choose type of plugin: " "WLX (lister)" "WCX (packer)" "WDX (content)" "WFX (file system)"
rem
ECHO RESULT=%RESULT%
EXIT /B 0
:CHOICE
SETLOCAL DISABLEDELAYEDEXPANSION
SET /A N=0
SET Q=%1
SHIFT
CALL :CHOICE_PRINT %1
IF ERRORLEVEL 1 (
ECHO need at least one option!
ENDLOCAL&EXIT /B 1
)
CALL :CHOICE_PRINT %2
IF ERRORLEVEL 1 GOTO CHOICE_PRINTDONE
CALL :CHOICE_PRINT %3
IF ERRORLEVEL 1 GOTO CHOICE_PRINTDONE
CALL :CHOICE_PRINT %4
IF ERRORLEVEL 1 GOTO CHOICE_PRINTDONE
CALL :CHOICE_PRINT %5
IF ERRORLEVEL 1 GOTO CHOICE_PRINTDONE
IF NOT x%6==x (
ECHO cannot handle more than 5 options!
ENDLOCAL&EXIT /B 1
)
:CHOICE_PRINTDONE
ECHO.
:CHOICE_ASK
SET /P choice=%Q:~1,-1%
IF %choice% LSS 1 (
ECHO Invalid choice %choice%, try again!
GOTO :CHOICE_ASK
)
IF %choice% GTR %N% (
ECHO Invalid choice %choice%, try again!
GOTO :CHOICE_ASK
)
ENDLOCAL&SET RESULT=%choice%
EXIT /B 0
:CHOICE_PRINT
IF x%1==x EXIT /B 1
SET X=%1
SET /A N=%N%+1
ECHO %N%: %X:~1,-1%
EXIT /B 0