diff -r cc26fdf57bb2 rc/bin/weather --- a/rc/bin/weather Sat Mar 13 14:57:53 2021 +0100 +++ b/rc/bin/weather Fri Apr 02 07:43:32 2021 -0700 @@ -3,14 +3,21 @@ rfork e DEFAULT=ewr +p = 'no' fn usage{ - echo 'usage: weather 3-letter-city-code' >[1=2] - echo 'for a list of cities in new york, say' >[1=2] - echo ' weather ny' >[1=2] + echo 'usage: weather [-p] [location]' >[1=2] exit usage } - +while (~ $1 -*){ + switch($1){ + case '-p' + p='yes' + shift + case * + usage + } +} switch($#*){ case 0 arg=$DEFAULT @@ -22,25 +29,6 @@ usage } -switch($arg){ -case [a-zA-Z][a-zA-Z][a-zA-Z] - script=('' '' 'C' '4' '1' '1' $arg '' '' '' '' 'X') -case [a-zA-Z][a-zA-Z] - script=('' '' 'C' '4' '1' '3' $arg '' '' '' '' 'X') -case * - usage -} - -{ - for(i in $script) - echo $i -} | -con -nrl tcp!rainmaker.wunderground.com!telnet | -sed -n '/Enter .-letter .* code:/,/CITY FORECAST MENU/p' | -sed 's/Enter .-letter .* code: //' | -sed 's/ Press Return to continue, M to return to menu, X to exit: //' | -grep -v 'CITY FORECAST MENU' | -tr -d '' | -sed 's/ *$//' | -uniq | -sed -n '/^VTEC/q; p' +if (~ $p 'no') hget 'http://wttr.in/'$arg'?format=%25t%20%25C' +if not hget http://wttr.in/~$arg.png | page +echo diff -r cc26fdf57bb2 sys/man/1/weather --- a/sys/man/1/weather Sat Mar 13 14:57:53 2021 +0100 +++ b/sys/man/1/weather Fri Apr 02 07:43:32 2021 -0700 @@ -4,37 +4,29 @@ .SH SYNOPSIS .B weather [ -.I air -] [ -.I st +.I -p +] +[ +.I location ] .SH DESCRIPTION .I Weather -prints the local conditions and seven-day forecast most recently reported at the -.SM US -airport with the three-letter location identifier -.IR air . -Given a two-letter -.SM US -state abbreviation -.I st -instead, -.I weather -prints a table of -.I air -location identifiers known for -.IR st . -.PP -The arguments are mutually exclusive and case-insensitive. -If neither is given, -.I air -defaults to the value of the environment variable -.BR $weather , -or if it is unset, -to the location identifier -.BR ewr , -designating the Newark, NJ, airport near Bell Labs, Murray Hill. +prints the current conditions or, with the -p option, a picture of the three-day forecast. The location is specified either by the location argument or the $weather environment variable. If no location is specified the Newark, NJ, airport near Bell Labs, Murray Hill is used. + +Weather may not output you city by default, For example: + + weather portland + +Returns Portland Oregon's weather. You can bypass this by appending a '-' followed by the name of the state/province/country where the city your looking for is located, For example: + + weather portland-iceland + +Returns the weather for Portland Iceland. + .SH SOURCE .B /rc/bin/weather .SH BUGS Weather is hopelessly provincial. + +There should be a better plain text output +