-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·210 lines (187 loc) · 4.12 KB
/
run.sh
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/bin/bash
alias cls='echo -en "\ec"'
shopt -s expand_aliases
file=""
toggle="false"
use_file="false"
echo This program will run the nilakantha algorithm to determine the value of pi to a decimal precision you specify.
function javascript() {
echo [1] Node.js
echo [2] Browser
echo [B] Back
read -p "Enter runtime: " input
if [[ $input == 1 ]]; then
echo Node.js
echo ""
cd js
if [[ $use_file == "true" ]]; then
node index-node.js < ../$file
else
node index-node.js
fi
cd ..
elif [[ $input == 2 ]]; then
echo Browser
echo ""
xdg-open js/index.js
elif [[ $input == B || $input == b ]]; then
main
else
javascript
fi
}
function main() {
echo --MENU--
echo [1] C
echo [2] C++
echo [3] Python
echo [4] Ruby
echo [5] JavaScript
echo [B] Back
if [[ $toggle == "true" ]]; then
if [[ $file != "" ]]; then
use_file="true"
else
use_file="false"
fi
else
use_file="false"
fi
read -p "Enter language: " input
if [[ $input == 1 ]]; then
echo -------------------- C --------------------
cd C
if [[ $use_file == "true" ]]; then
./nilakantha < ../$file
else
./nilakantha
fi
cd ..
elif [[ $input == 2 ]]; then
echo -------------------- C++ --------------------
cd C++
if [[ $use_file == "true" ]]; then
./nilakantha < ../$file
else
./nilakantha
fi
cd ..
elif [[ $input == 3 ]]; then
echo -------------------- Python --------------------
cd python
if [[ $use_file == "true" ]]; then
python3 -i nilakantha.py < ../$file
else
python3 -i nilakantha.py
fi
cd ..
elif [[ $input == 4 ]]; then
echo -------------------- Ruby --------------------
if [[ $use_file == "true" ]]; then
ruby nilakantha.rb < ../$file
else
ruby nilakantha.rb
fi
elif [[ $input == 5 ]]; then
echo -------------------- JavaScript --------------------
javascript
elif [[ $input == B || $input == b ]]; then
menu
fi
echo ""
main
}
function settings() {
cls
echo --Settings--
if [[ $toggle == "false" ]]; then
echo Input file toggled off
elif [[ $file == "" ]]; then
echo No input file set
else
echo Input file set to be $file
fi
echo ""
echo [I] Set standard input file
echo [T] Toggle input file on/off
echo [G] Generate output file
echo [R] Reset output file
echo [S] Setup - compile C and C++
echo [B] Back
read -p "Enter Menu Option: " input
if [[ $input == "B" || $input == "b" ]]; then
menu
elif [[ $input == "T" || $input == "t" ]]; then
if [[ $toggle == "true" ]]; then
toggle="false"
else
toggle="true"
fi
elif [[ $input == "I" || $input == "i" ]]; then
cls
echo --Set Input File--
directory=`pwd`
read -p "Enter File Path from ${directory} " file
toggle="true"
echo $file
elif [[ $input == "G" || $input == "g" ]]; then
cls
directory=`pwd`
echo --Generating output file to ${directory}--
echo nilakantha algorithm performance test > out.txt
echo "" >> out.txt
if [[ -f C/out.part ]]; then
echo --C-- >> out.txt
cat C/out.part >> out.txt
fi
if [[ -f C++/out.part ]]; then
echo --C++-- >> out.txt
cat C++/out.part >> out.txt
fi
if [[ -f python/out.part ]]; then
echo --python-- >> out.txt
cat python/out.part >> out.txt
fi
if [[ -f ruby/out.part ]]; then
echo --ruby-- >> out.txt
cat ruby/out.part >> out.txt
fi
if [[ -f js/out.part ]]; then
echo --JavaScript-- >> out.txt
cat js/out.part >> out.txt
fi
read -p "Press any key to continue..."
settings
elif [[ $input == "R" || $input == "r" ]]; then
rm C/out.part
rm C++/out.part
rm python/out.part
rm ruby/out.part
rm js/out.part
cls
echo --Deleted all program-specific output files--
read -p "Press any key to continue..."
elif [[ $input == "S" || $input == "s" ]]; then
gcc C/nilakantha.c -o C/nilakantha -lm
g++ C++/nilakantha.cpp -o C++/nilakantha
cls
echo --Compiled C and C++--
read -p "Press any key to continue..."
fi
settings
}
function menu() {
cls
echo --MENU--
echo [L] Language Select
echo [S] Settings
read -p "Enter Menu Option: " input
if [[ $input == "L" || $input == "l" ]]; then
cls
main
elif [[ $input == "S" || $input == "s" ]]; then
settings
fi
menu
}
menu