From 87579b5eda6f410de1a71e2b18d898fd2344bb6d Mon Sep 17 00:00:00 2001 From: stkhan Date: Tue, 30 Apr 2024 11:59:43 -0500 Subject: updates --- README | 3 +++ nws | 27 +++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 README diff --git a/README b/README new file mode 100644 index 0000000..3712628 --- /dev/null +++ b/README @@ -0,0 +1,3 @@ +nws - a command-line weather service + +nws retrieves data from the National Weather Service, and displays it in you're terminal. diff --git a/nws b/nws index 581b305..26bd8ed 100755 --- a/nws +++ b/nws @@ -90,18 +90,37 @@ show_spc() { } get_forecast() { + colors get_location curl $(curl https://api.weather.gov/points/$cords | jq -r .properties.forecast) >> ~/.cache/.weather_forecast - echo $(jq .properties.periods[0].name ~/.cache/.weather_forecast | sed 's/"//g'): + count=0 + length=$(echo $(jq '.properties.periods | length' ~/.cache/.weather_forecast) -1 | bc) + while [ $count -le $length ] + do + echo ---------------------------------------------------------------------------------------------------- + echo -e ${GREEN}Day: ${NOCOLOR}$(jq '.properties.periods['$count'].name' ~/.cache/.weather_forecast) + echo -e ${GREEN}Temperature: ${NOCOLOR}$(jq '.properties.periods['$count'].temperature' ~/.cache/.weather_forecast)$(jq '.properties.periods['$count'].temperatureUnit' ~/.cache/.weather_forecast) + echo -e ${GREEN}Rain chance: ${NOCOLOR}$(jq '.properties.periods['$count'].probabilityOfPrecipitation.value' ~/.cache/.weather_forecast)% + echo -e ${GREEN}Wind: ${NOCOLOR}$(jq '.properties.periods['$count'].windDirection' ~/.cache/.weather_forecast), $(jq '.properties.periods['$count'].windSpeed' ~/.cache/.weather_forecast) + echo + echo $(jq '.properties.periods['$count'].detailedForecast' ~/.cache/.weather_forecast) + echo + echo ---------------------------------------------------------------------------------------------------- + echo + echo + ((count++)) + done echo "" } help() { - echo "tw" + echo "nws" echo " --full-radar: shows radar of entire US" echo " --radar: shows local radar" echo " --spc: shows storm predictions" echo " --retrieve-counties: shows county ids" + echo " --ca: shows number of alerts" + echo " -a: shows alerts" echo " -f: shows local forecast" } @@ -113,8 +132,8 @@ case $1 in '--retrieve-counties') retrieve_counties;; '--ca') count_alerts;; '-t') show_timing;; - '-a') show_alerts | less -R;; - '-f') get_forecast;; + '-a') show_alerts | sed 's/null//g ; s/"//g' |less -R;; + '-f') get_forecast | sed 's/"//g' | less -R;; '-h') help;; "") help;; esac -- cgit v1.2.3