-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmojolings.bash
executable file
·57 lines (51 loc) · 1.43 KB
/
mojolings.bash
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
#!/bin/bash
# TODO
# - maybe don't show previous exercises while in interactive mode?
# - some message when all exercises are done?
# - % completed in full mode?
clear
exercise_dir="exercises"
full_check=0
while test $# -gt 0; do
case "$1" in
-f|--full)
full_check=1
shift
;;
# debug!
-s|--solutions)
exercise_dir="solutions"
shift
;;
esac
done
if [ $full_check -eq 1 ]; then
for exercise in $exercise_dir/*.mojo; do
output=$(mojo $exercise 2>&1)
if [ $? -eq 0 ]; then
echo "✅ $(basename $exercise)"
else
echo "❌ $(basename $exercise)"
fi
done
else
for exercise in $exercise_dir/*.mojo; do
head -n 1 $exercise | grep "I'M NOT DONE" &> /dev/null
if [ $? -ne 0 ]; then
echo "still debating if we show the previously completed exercises" > /dev/null
# echo "✅ $(basename $exercise)"
else
output=$(mojo $exercise 2>&1)
if [ $? -eq 0 ]; then
echo "✅ $(basename $exercise)"
echo -e "\n$output"
echo -e "\nRemove \"I'M NOT DONE\" from \"$(basename $exercise)\" to continue."
exit 0
else
echo "❌ $(basename $exercise)"
echo -e "\n$output"
exit 1
fi
fi
done
fi