Remove environment variable support

This commit is contained in:
Michael De Roover 2020-08-10 17:14:19 +02:00
parent 07d9734ba0
commit 02adb8dd79
Signed by: vim
GPG Key ID: 075496E232CE04CB
1 changed files with 13 additions and 17 deletions

30
cv
View File

@ -1,25 +1,30 @@
#!/bin/bash
# Variable declarations go here.
w=11
dfmt="+%Y-%m-%d"
data="$HOME/Documents/cv"
[ ! -d "$data" ] && ex "mkdir -p $data"
[ -z $date ] && date=$(date $dfmt)
[ -z $ydate ] && ydate=$(date -d yesterday $dfmt)
# Get yesterday's stats for queries after midnight.
if [ "$2" == "yesterday" ]
then
date=$(date -d yesterday $dfmt)
ydate=$(date -d "2 days ago" $dfmt)
fi
# Functions go here.
ex(){
echo -e "> ${*}"
$@
}
[ -z $date ] && date=$(date $dfmt)
[ -z $ydate ] && ydate=$(date -d yesterday $dfmt)
title(){
local w=39
printf "║ %-${w}s ║\n" "${*}"
}
data="$HOME/Documents/cv"
[ ! -d "$data" ] && ex "mkdir -p $data"
# If not set by an environment variable, set country to $1.
[ -z "$country" ] && country=$1
get(){
if [ -f "$data/$date-$country" ]
then
@ -95,15 +100,6 @@ result(){
}
# Main code starts here.
# Get yesterday's stats for queries after midnight.
# Not pretty but it works I guess...
if [ "$2" == "yesterday" ]
then
date=$(date -d yesterday $dfmt)
ydate=$(date -d "2 days ago" $dfmt)
fi
if [ ! -z "$country" ]
then
endpoint=countries/$country