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 date=$ydate
get "$1" 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(){ result(){
echo "Total: $(get cases)" out Total cases
echo "Active: $(get active)" out Active active
echo "New: $(get todayCases)" out New todayCases
echo "Deaths: $(get deaths)" out Deaths deaths
echo "Recovered: $(get recovered)" out Recovered recovered
echo "Tests: $(get tests)" out Tests tests
if [ -f "$data/$ydate-$country" ] if [ -f "$data/$ydate-$country" ]
then then
show "Yesterday's stats:" show "Yesterday's stats:"
echo "New: $(yget todayCases)" out New todayCases yesterday
if [ "$(get todayCases)" == "$(yget todayCases)" ] if [ "$(get todayCases)" == "$(yget todayCases)" ]
then then
show "Seems like the stats are the same as yesterday." show "Seems like the stats are the same as yesterday."