diff options
| author | stkhan <personal@slickd.xyz> | 2024-04-30 11:59:43 -0500 |
|---|---|---|
| committer | stkhan <personal@slickd.xyz> | 2024-04-30 11:59:43 -0500 |
| commit | 87579b5eda6f410de1a71e2b18d898fd2344bb6d (patch) | |
| tree | 0a0607bcc13f295c61866d8b6916da7017abdb32 | |
| parent | 03a25eb9ffe2c4e27a87b9469d07b431ba721e6a (diff) | |
updates
| -rw-r--r-- | README | 3 | ||||
| -rwxr-xr-x | nws | 27 |
2 files changed, 26 insertions, 4 deletions
@@ -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. @@ -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 |