1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-02 07:07:46 +00:00

fixed weather script so it's outputting structured data appropriately.

This commit is contained in:
Darren Schroeder 2021-12-07 13:37:27 -06:00
parent 0884d2c074
commit 89a089f3ce

View file

@ -119,21 +119,43 @@ def get_weather [
let with_loc_no_unit = ($is_loc_empty == $false && $is_units_empty == $true) 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) 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 { if $no_loc_no_unit {
(get_weather_by_ip 0 "f") (get_weather_by_ip 0 "f")
} { } } { if $no_loc_with_unit {
if $no_loc_with_unit {
(get_weather_by_ip 0 $units) (get_weather_by_ip 0 $units)
} { } } { if $with_loc_no_unit {
if $with_loc_no_unit {
(get_weather_by_ip $locIdx "f") (get_weather_by_ip $locIdx "f")
} { } } { if $with_loc_with_unit {
if $with_loc_with_unit {
(get_weather_by_ip $locIdx $units) (get_weather_by_ip $locIdx $units)
} { } } { } }}}
} }
def state_abbrev_lookup [state_name: string] { def state_abbrev_lookup [state_name: string] {