Refactor out function in cv
This commit is contained in:
parent
a55248f232
commit
a01fb55a86
27
cv
27
cv
@ -36,7 +36,7 @@ get(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
getpct(){
|
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(){
|
yget(){
|
||||||
date=$ydate
|
date=$ydate
|
||||||
@ -47,8 +47,11 @@ yget(){
|
|||||||
echo 0
|
echo 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
stats(){
|
||||||
|
out "$1:" "$(get $2)" "+ $(echo "scale = 2; $(get $2) - $(yget $2)" | bc)"
|
||||||
|
}
|
||||||
out(){
|
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(){
|
frame(){
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -66,16 +69,16 @@ result(){
|
|||||||
title "Queried at: $date"
|
title "Queried at: $date"
|
||||||
frame up
|
frame up
|
||||||
frame table
|
frame table
|
||||||
out Total cases
|
stats Total cases
|
||||||
out "╰> Per 1M " casesPerOneMillion
|
stats "╰> Per 1M " casesPerOneMillion
|
||||||
out Active active
|
stats Active active
|
||||||
out Critical critical
|
stats Critical critical
|
||||||
out New todayCases
|
stats New todayCases
|
||||||
out Deaths deaths
|
stats Deaths deaths
|
||||||
out "╰> Per 1M " deathsPerOneMillion
|
stats "╰> Per 1M " deathsPerOneMillion
|
||||||
out Recovered recovered
|
stats Recovered recovered
|
||||||
out Tests tests
|
stats Tests tests
|
||||||
out "╰> Per 1M " testsPerOneMillion
|
stats "╰> 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
|
||||||
|
Reference in New Issue
Block a user