Refactor out function in cv
This commit is contained in:
parent
a55248f232
commit
a01fb55a86
27
cv
27
cv
|
@ -36,7 +36,7 @@ get(){
|
|||
fi
|
||||
}
|
||||
getpct(){
|
||||
printf "║ %-${w}s ║ %${w}s ║ %-${w}s ║\n" "" "$(echo "$(bc <<< "scale = 1; $(get $1) / 10000") %")" ""
|
||||
out "" "$(echo "$(bc <<< "scale = 1; $(get $1) / 10000") %")" ""
|
||||
}
|
||||
yget(){
|
||||
date=$ydate
|
||||
|
@ -47,8 +47,11 @@ yget(){
|
|||
echo 0
|
||||
fi
|
||||
}
|
||||
stats(){
|
||||
out "$1:" "$(get $2)" "+ $(echo "scale = 2; $(get $2) - $(yget $2)" | bc)"
|
||||
}
|
||||
out(){
|
||||
printf "║ %-${w}s ║ %${w}s ║ %-${w}s ║\n" "$1:" "$(get $2)" "+ $(echo "scale = 2; $(get $2) - $(yget $2)" | bc)"
|
||||
printf "║ %-${w}s ║ %${w}s ║ %-${w}s ║\n" "$1" "$2" "$3"
|
||||
}
|
||||
frame(){
|
||||
case "$1" in
|
||||
|
@ -66,16 +69,16 @@ result(){
|
|||
title "Queried at: $date"
|
||||
frame up
|
||||
frame table
|
||||
out Total cases
|
||||
out "╰> Per 1M " casesPerOneMillion
|
||||
out Active active
|
||||
out Critical critical
|
||||
out New todayCases
|
||||
out Deaths deaths
|
||||
out "╰> Per 1M " deathsPerOneMillion
|
||||
out Recovered recovered
|
||||
out Tests tests
|
||||
out "╰> Per 1M " testsPerOneMillion
|
||||
stats Total cases
|
||||
stats "╰> Per 1M " casesPerOneMillion
|
||||
stats Active active
|
||||
stats Critical critical
|
||||
stats New todayCases
|
||||
stats Deaths deaths
|
||||
stats "╰> Per 1M " deathsPerOneMillion
|
||||
stats Recovered recovered
|
||||
stats Tests tests
|
||||
stats "╰> Per 1M " testsPerOneMillion
|
||||
getpct testsPerOneMillion
|
||||
if [ ! -f $data/$ydate-$country ] || [ $(get todayCases) == "0" ]
|
||||
then
|
||||
|
|
Reference in New Issue