From e494d2dada00f0c4b48cc14fd70f5561e0407a97 Mon Sep 17 00:00:00 2001 From: Michael De Roover Date: Sun, 17 May 2020 19:36:15 +0200 Subject: [PATCH] Make spacing in output adjustable --- cv | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/cv b/cv index d9e3152..ed4afd9 100755 --- a/cv +++ b/cv @@ -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."