-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrascal
More file actions
executable file
·72 lines (51 loc) · 1.38 KB
/
rascal
File metadata and controls
executable file
·72 lines (51 loc) · 1.38 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
68
69
70
71
72
#!/bin/bash
# make sure we have openjdk installed
if [[ ! -f /opt/homebrew/opt/openjdk/bin/java ]]
then
echo "please install openjdk with this command:"
echo "brew install openjdk"
fi
# let's make sure we have the github cli
if [[ ! -d /opt/homebrew/opt/gh ]]
then
echo "please run these commands to set up the github cli:"
echo "brew install gh"
echo "gh login"
exit 1
fi
# let's make sure we have the rasccal jar
if [[ -z "$(find ~/.rascal -type f -regex ".*[0-9].jar")" ]]
then
echo "test"
mkdir -p ~/.rascal
# invocation should be something like this
gh release download -R github.com/usethesource/rascal --pattern "*[0-9].jar" -D ~/.rascal/
fi
fileFound=""
if [[ -f $1 ]]
then
fileFound="$1"
fi
if [[ -f "${1}.rsc" ]]
then
fileFound="${1}.rsc"
fi
if [[ ! -z "$fileFound" ]]
then
module=`head -n 1 $fileFound | sed 's/module *//'`
if [[ -z $module ]]
then
echo "no module declared in source file"
exit 1
fi
tmpDir=`mktemp -d`
mkdir $tmpDir/META-INF
echo "Project-Name: convenientRascal" > $tmpDir/META-INF/RASCAL.MF
echo "Source: src/$module/rascal" >> $tmpDir/META-INF/RASCAL.MF
mkdir -p $tmpDir/src/$module/rascal
cp $fileFound $tmpDir/src/$module/rascal/
cd $tmpDir
/opt/homebrew/opt/openjdk/bin/java -jar ~/.rascal/rascal-*.jar $fileFound ${@:2}
exit 0
fi
/opt/homebrew/opt/openjdk/bin/java -jar ~/.rascal/rascal-*.jar $@