-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateAll.sh
executable file
·67 lines (63 loc) · 1.58 KB
/
updateAll.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
#!bash
file="README.md"
#auto clang-format
clang-format -style=file -i */*.[ch]*
#write Readme
function printLevel {
local level=`cat questionLevel | fgrep -w $1 | cut -f 2`
printf " " >> $file
for i in $(seq 5)
do
if [ $i -le $level ]; then
echo -n "★" >> $file
else
echo -n "☆" >> $file
fi
done
echo -n " |" >> $file
}
#update Readmetext
temp=`cat $file| fgrep -on "### 完成的" | cut -f 1 -d ':' `
head -n $temp $file > new_README.md
rm $file
mv new_README.md $file
#update ReadmeTable
echo -e "- 共<b> "`ls | sort -n | grep '[0-9]' | wc -w`" </b>題\n" >> $file
echo '| 題號 | 星數 | source code | screenshot | makefile | solution.txt |' >> $file
echo '| :--------: | :--------: | :--------: | :--------: | :--------: | :--------: |' >> $file
lack=()
for problemNum in $(ls | sort -n | grep '[0-9]')
do
echo -n "| <b>$problemNum</b> |" >> $file
printLevel $problemNum
if [ -e $problemNum\/$problemNum.* ]; then
echo -n ' O |' >> $file
else
echo -n ' <b>X</b> |' >> $file
lack+=("$problemNum source code")
fi
if [ -e $problemNum\/*Screenshot* ]; then
echo -n ' O |' >> $file
else
echo -n ' <b>X</b> |' >> $file
lack+=("$problemNum screenshot")
fi
if [ -e $problemNum\/[Mm]akefile ]; then
echo -n ' O |' >> $file
else
echo -n ' <b>X</b> |' >> $file
lack+=("$problemNum makefile")
fi
if [ -e $problemNum\/[sS]olution.txt ]; then
echo -n ' O |' >> $file
else
echo -n ' <b>X</b> |' >> $file
lack+=("$problemNum solution.txt")
fi
echo >>$file
done
# print out which file needed to terminal
for line in "${lack[@]}"
do
echo updateAll: need $line
done