From 89a089f3cef12c2d39e593fad62c9d8b7ed5835f Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Tue, 7 Dec 2021 13:37:27 -0600 Subject: [PATCH] fixed weather script so it's outputting structured data appropriately. --- weather/get-weather.nu | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/weather/get-weather.nu b/weather/get-weather.nu index 9b0565d..89ff25b 100644 --- a/weather/get-weather.nu +++ b/weather/get-weather.nu @@ -119,21 +119,43 @@ def get_weather [ let with_loc_no_unit = ($is_loc_empty == $false && $is_units_empty == $true) let with_loc_with_unit = ($is_loc_empty == $false && $is_units_empty == $false) + # This is a cautionary tale, the commented out code below is returning + # and autoview is viewing the data, so no structured data is being returned. + # The ramification to this is you can't do get_weather | select Temperature Emoji + # like you should be able to. The following uncommented section below fixes it. + + # Hopefully we'll be able to fix this somehow because it's easy to fall into + # this hole without knowing. + + # if $no_loc_no_unit { + # echo "no_loc_no_unit" + # (get_weather_by_ip 0 "f") + # } { } + + # if $no_loc_with_unit { + # echo "no_loc_with_unit" + # (get_weather_by_ip 0 $units) + # } { } + + # if $with_loc_no_unit { + # echo "with_loc_no_unit" + # (get_weather_by_ip $locIdx "f") + # } { } + + # if $with_loc_with_unit { + # echo "with_loc_with_unit" + # (get_weather_by_ip $locIdx $units) + # } { } + if $no_loc_no_unit { (get_weather_by_ip 0 "f") - } { } - - if $no_loc_with_unit { + } { if $no_loc_with_unit { (get_weather_by_ip 0 $units) - } { } - - if $with_loc_no_unit { + } { if $with_loc_no_unit { (get_weather_by_ip $locIdx "f") - } { } - - if $with_loc_with_unit { + } { if $with_loc_with_unit { (get_weather_by_ip $locIdx $units) - } { } + } { } }}} } def state_abbrev_lookup [state_name: string] {