From 02adb8dd79a599363a096721f7ed7ee379677754 Mon Sep 17 00:00:00 2001 From: Michael De Roover Date: Mon, 10 Aug 2020 17:14:19 +0200 Subject: [PATCH] Remove environment variable support --- cv | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/cv b/cv index cf124bc..8ad968b 100755 --- a/cv +++ b/cv @@ -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