-
Notifications
You must be signed in to change notification settings - Fork 1
/
args.bat
93 lines (74 loc) · 1.73 KB
/
args.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
@echo off
rem Constants
set sbcl="sbcl"
set ccl="ccl"
set clisp="clisp"
set ecl="ecl"
set abcl="abcl"
rem Get the name of the script itself.
set self=%~n0%~x0
rem Get the root path of current batch script.
set rootdir=%~dp0
rem Get first argument.
set lisp=%1
if "" == "%lisp%" goto hint
if "/?" == "%lisp%" goto hint
if "usage" == "%lisp%" goto usage
if "help" == "%lisp%" goto usage
if %sbcl% == "%lisp%" goto runlisp
if %ccl% == "%lisp%" goto runlisp
if %clisp% == "%lisp%" goto runlisp
if %ecl% == "%lisp%" goto runlisp
if %abcl% == "%lisp%" goto runlisp
echo Unsupported Common Lisp implementation
exit /B 1
:hint
echo Use `%self% usage` or `%self% help` to show help info
exit /B 0
:usage
echo Usage: %self% [lisp] [param] ...
echo.
echo Valid Common Lisp implementation:
echo sbcl
echo ccl
echo clisp
echo ecl
echo abcl
exit /B 0
:runlisp
rem Consume first argument.
shift
rem Collect remaining argument(s).
set args=
:collect_args
set arg=%1
shift
if "" neq "%arg%" set args=%args% %arg% && goto collect_args
rem Run specific Common Lisp implementation.
if %sbcl% == "%lisp%" goto runsbcl
if %ccl% == "%lisp%" goto runccl
if %clisp% == "%lisp%" goto runclisp
if %ecl% == "%lisp%" goto runecl
if %abcl% == "%lisp%" goto runabcl
rem Fallback as some error message.
echo Unknown Common Lisp implementation
exit /B 1
:runsbcl
sbclrun %rootdir%args.lisp %args%
exit /B 0
:runccl
rem `ccl` is a Clozure CL wrapper.
rem Hence, there is no need to add `--` here.
ccl %rootdir%args.lisp %args%
exit /B 0
:runclisp
clisp %rootdir%args.lisp %args%
exit /B 0
:runecl
ecl -shell %rootdir%args.lisp %args%
exit /B 0
:runabcl
rem `abcl` is an Armed Bear CL wrapper.
rem Hence, there is no need to add `--` here.
abcl %rootdir%args.lisp %args%
exit /B 0