diff --git a/cv b/cv index da18d97..bb9d75f 100755 --- a/cv +++ b/cv @@ -6,6 +6,7 @@ then else # This is a compatibility mode and not well-supported. date=$(date +"%Y-%m-%d") + ydate=$(date -d yesterday +"%Y-%m-%d") show(){ echo -e "\033[1;36m> ${@} \033[0m" } @@ -31,16 +32,32 @@ get(){ cat $data/$date-$country fi } +yget(){ + date=$ydate + get +} result(){ echo "Total: $(get | jq -r '.cases')" echo "Active: $(get | jq -r '.active')" - echo "Today: $(get | jq -r '.todayCases')" + echo "New: $(get | jq -r '.todayCases')" echo "Tests: $(get | jq -r '.tests')" + show "Yesterday's stats:" + echo "New: $(yget | jq -r '.todayCases')" if [ $(get | jq -r '.todayCases') == "0" ] then show "Seems like the cases today are not yet updated." show "The data file will be removed. Please query again later." ex "rm $data/$date-$country" + elif [ $(get | jq -r '.todayCases') == $(yget | jq -r '.todayCases') ] + then + show "Seems like the stats are the same as yesterday." + show "This could be normal but may mean that the data file is still yesterday's." + show "Do you want to remove it? (y/n)" + read answer + if [ "$answer" == "y" ] + then + ex "rm $data/$date-$country" + fi fi }