This repository has been archived on 2022-06-10. You can view files and clone it, but cannot push or open issues or pull requests.
cv/cv

49 lines
848 B
Bash
Executable File

#!/bin/bash
if [ -f /usr/local/bin/vars ]
then
. /usr/local/bin/vars
else
# This is a compatibility mode and not well-supported.
date=$(date +"%Y-%m-%d")
show(){
echo -e "\033[1;36m> ${@} \033[0m"
}
fi
country=$1
get(){
if [ -f /tmp/cv/$date-$country ]
then
cat /tmp/cv/$date-$country
else
curl -sL corona.lmao.ninja/v2/$endpoint > /tmp/cv/$date-$country
cat /tmp/cv/$date-$country
fi
}
result(){
echo "Total: $(get | jq -r '.cases')"
echo "Active: $(get | jq -r '.active')"
echo "Today: $(get | jq -r '.todayCases')"
echo "Tests: $(get | jq -r '.tests')"
}
show "Queried at: $date"
if [ ! -z $country ]
then
if [ "$country" == "all" ]
then
endpoint=all
result
else
endpoint=countries/$country
result
fi
else
country=Belgium
show "Country has been set to $country."
endpoint=countries/$country
result
fi