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

Merge pull request #113 from fdncred/weather_fix

fixed weather script so it's outputting structured data appropriately.
This commit is contained in:
Darren Schroeder 2021-12-07 13:38:23 -06:00 committed by GitHub
commit 3603fa04f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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_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] {