shithub: rc

ref: c1a707427fbbb5129e467516fc671e976ee3e398
dir: /weather/

View raw version
#!/bin/rc
# weather(1) - by Fulton Browne - MIT Licence
# https://github.com/chubin/wttr.in
# https://wttr.in/:help
# BROKEN: https://github.com/chubin/wttr.in/issues/1095

rfork e

DEFAULT=Indianapolis
p = 'no'

fn usage{
	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
	if(~ $#weather 1)
		arg=$weather
case 1
	arg=$1
case *
	usage
}

if (~ $p 'no') hget 'http://wttr.in/'$arg'?u&format=%25t%20%25C'
if not hget http://wttr.in/~$arg.png'?'u | page
echo