Change table width to 11

Also replace assumption of no cv arguments with worldwide stats instead of Belgium
This commit is contained in:
Michael De Roover 2020-08-09 00:55:06 +02:00
parent 9d8a5d64ca
commit 28c59e5ee2
Signed by: vim
GPG Key ID: 075496E232CE04CB

33
cv
View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
w=10 w=11
dfmt="+%Y-%m-%d" dfmt="+%Y-%m-%d"
ex(){ ex(){
@ -10,7 +10,7 @@ ex(){
[ -z $date ] && date=$(date $dfmt) [ -z $date ] && date=$(date $dfmt)
[ -z $ydate ] && ydate=$(date -d yesterday $dfmt) [ -z $ydate ] && ydate=$(date -d yesterday $dfmt)
title(){ title(){
local w=36 local w=39
printf "║ %-${w}s ║\n" "${*}" printf "║ %-${w}s ║\n" "${*}"
} }
@ -46,28 +46,28 @@ out(){
} }
frame(){ frame(){
case "$1" in case "$1" in
top) printf "╔══════════════════════════════════════╗\n" ;; top) printf "╔═════════════════════════════════════════╗\n" ;;
table) printf "║ Statistic ║ Today ║ Yesterday ║\n" table) printf "║ Statistic Today ║ Yesterday ║\n"
printf "╟────────────╫────────────╫────────────╢\n" ;; printf "╟────────────────────────╫────────────╢\n" ;;
up) printf "╠════════════╦════════════╦════════════╣\n" ;; up) printf "╠════════════════════════╦════════════╣\n" ;;
down) printf "╚════════════╩════════════╩════════════╝\n" ;; down) printf "╚════════════════════════╩════════════╝\n" ;;
line) printf "╠════════════╩════════════╩════════════╣\n" ;; line) printf "╠════════════════════════╩════════════╣\n" ;;
bot) printf "╚══════════════════════════════════════╝\n" ;; bot) printf "╚═════════════════════════════════════════╝\n" ;;
esac esac
} }
result(){ result(){
frame up frame up
frame table frame table
out Total cases out Total cases
out "╰> Per 1M" casesPerOneMillion out "╰> Per 1M " casesPerOneMillion
out Active active out Active active
out Critical critical out Critical critical
out New todayCases out New todayCases
out Deaths deaths out Deaths deaths
out "╰> Per 1M" deathsPerOneMillion out "╰> Per 1M " deathsPerOneMillion
out Recovered recovered out Recovered recovered
out Tests tests out Tests tests
out "╰> Per 1M" testsPerOneMillion out "╰> Per 1M " testsPerOneMillion
getpct testsPerOneMillion getpct testsPerOneMillion
if [ ! -f $data/$ydate-$country ] || [ $(get todayCases) == "0" ] if [ ! -f $data/$ydate-$country ] || [ $(get todayCases) == "0" ]
then then
@ -106,18 +106,19 @@ frame top
title "Queried at: $date" title "Queried at: $date"
if [ ! -z "$country" ] if [ ! -z "$country" ]
then then
# This is to be phased out in favor of worldwide stats
# in the else statement.
if [ "$country" == "all" ] if [ "$country" == "all" ]
then then
endpoint=all endpoint=all
country=world
result result
else else
endpoint=countries/$country endpoint=countries/$country
result result
fi fi
else else
# Change this to your own country as desired. endpoint=all
country=Belgium country=world
title "Country has been set to $country."
endpoint=countries/$country
result result
fi fi