Remind me to do this in Python next time 😬

This commit is contained in:
Chad Whitacre 2021-03-20 20:28:13 -04:00
parent c01bd1059c
commit c646d8af7f

View File

@ -20,10 +20,12 @@ done
sort -nro port-done{,}
sort -nro port-todo{,}
echo " loc files" > port-summary
echo " -------- -----" >> port-summary
echo " wc -l files" > port-summary
echo " -------- -----" >> port-summary
function summarize {
printf "$1 " | cut -d"-" -f2 | tr -d '\n'
printf " "
printf "$1" | cut -d"-" -f2 | tr -d '\n'
printf " "
awk '{ loc += $1 } END { printf "%6d",loc }' "$1"
printf " "
wc -l "$1" | awk '{ printf "%3d",$1 }'
@ -31,3 +33,24 @@ function summarize {
} >> port-summary
summarize port-done
summarize port-todo
printf " total " >> port-summary
function sum {
ndone=$(head -n3 port-summary | tail -n1 | awk "{ print \$$1 }")
ntodo=$(head -n4 port-summary | tail -n1 | awk "{ print \$$1 }")
echo "$ndone + $ntodo" | bc -s
}
printf " $(sum 2)" >> port-summary
printf " $(sum 3)" >> port-summary
echo >> port-summary
echo >> port-summary
printf "%% todo " >> port-summary
function perc {
ndone=$(head -n3 port-summary | tail -n1 | awk "{ print \$$1 }")
ntodo=$(head -n4 port-summary | tail -n1 | awk "{ print \$$1 }")
echo "r = ($ntodo / ($ndone + $ntodo)) * 100; scale=0; r / 1" | bc -sl
}
printf " $(perc 2)" >> port-summary
printf " $(perc 3)" >> port-summary
echo >> port-summary