AdventOfCode2023/make_readme.sh

18 lines
856 B
Bash
Raw Normal View History

2023-12-06 12:15:51 +01:00
#!/bin/bash
2023-12-09 11:53:29 +01:00
table="| Day | Language | Lines of code | Execuction time | Comment |\n"
2023-12-09 11:54:33 +01:00
table+="|:---:|:---:| ---:| ---: |--- |\n"
2023-12-06 12:15:51 +01:00
for day in $(seq -f "%02g" 1 25); do
[[ ! -d "$day" ]] && continue
# echo $day
2023-12-08 13:52:28 +01:00
lang=$(grep -E "Today's language:" $day/README.md | sed -r 's/.*\*\*(.+)\*\*.*/\1/')
exectime=$(grep -E "Execution time:" $day/README.md | sed -r 's/.*\*\*(.+)\*\*.*/\1/')
2023-12-09 11:53:29 +01:00
loc=$(grep -E "Lines of code:" $day/README.md | sed -r 's/.*\*\*(.+)\*\*.*/\1/')
2023-12-06 12:15:51 +01:00
comment=$(grep -E "<!-- .* -->" $day/README.md | head -1 | sed -r 's/.*<!-- *(.*) *-->.*/\1/')
2023-12-09 11:53:29 +01:00
table+="| [$day]($day) | $lang | $loc | $exectime | $comment |\n"
2023-12-06 12:15:51 +01:00
done
# remove table from readme
sed -i '/<!-- table begin -->/q' README.md
echo -e $table | column -t -s '|' -o '|' >> README.md
2023-12-09 11:53:29 +01:00
echo -e "\n Lines of code are without blank lines and comments" >> README.md