Make spacing in output adjustable

This commit is contained in:
Michael De Roover 2020-05-17 19:36:15 +02:00
parent 11c28758a2
commit e494d2dada
Signed by: vim
GPG Key ID: 075496E232CE04CB

23
cv
View File

@ -44,17 +44,26 @@ yget(){
date=$ydate
get "$1"
}
out(){
w=10
if [ -z $3 ]
then
printf "%-${w}s %d\n" "$1:" "$(get $2)"
else
printf "%-${w}s %d\n" "$1:" "$(yget $2)"
fi
}
result(){
echo "Total: $(get cases)"
echo "Active: $(get active)"
echo "New: $(get todayCases)"
echo "Deaths: $(get deaths)"
echo "Recovered: $(get recovered)"
echo "Tests: $(get tests)"
out Total cases
out Active active
out New todayCases
out Deaths deaths
out Recovered recovered
out Tests tests
if [ -f "$data/$ydate-$country" ]
then
show "Yesterday's stats:"
echo "New: $(yget todayCases)"
out New todayCases yesterday
if [ "$(get todayCases)" == "$(yget todayCases)" ]
then
show "Seems like the stats are the same as yesterday."