Initial state of cv

This commit is contained in:
Michael De Roover 2020-04-30 13:00:52 +02:00
commit d84bc9fb23
Signed by: vim
GPG Key ID: 075496E232CE04CB
1 changed files with 39 additions and 0 deletions

39
cv Executable file
View File

@ -0,0 +1,39 @@
#!/bin/bash
. /usr/local/bin/vars
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