Hacker News new | ask | show | jobs
Weatherme CLI Tool (github.com)
50 points by eoinbarr 1297 days ago
14 comments

I suppose this is as good a time as any to plug noaa, a CLI tool that can give you the current conditions and forecast, but also allows you to retrieve any product the US National Weather Service produces. It’s way geekier than the above, but perhaps more useful for some.

https://github.com/sramsay/nowa/

(I am also the author of wu, which was a popular cli tool for the Weather Underground API. I had to discontinue that when they closed free access to their API. That was written in Go; this one is written in C).

Thank you for wu and this too, Please enlighten me on why nowa is written in C, would you?
As always, you should feel free to rewrite in whatever Better Language™ you prefer.
The usual reasons, I suppose (speed, portability, ubiquity . . .) Do you mean as opposed to Go?
Using curl, jq and api.weather.gov. See docs for more info. Use Google Maps or equivalent to get lat long.

  # Set this:
 
  latlong='33.7737,-118.1365'

  url=$(curl -sS "https://api.weather.gov/points/$latlong" | jq -r '.properties.forecastHourly')
  curl -sS "$url" | jq -r '.properties | .periods[0].temperature, .generatedAt'

Using Python.

  import requests
  
  # Set this:
  latlong = '33.7737,-118.1365'
  
  session = requests.Session()
  
  url = session.get('https://api.weather.gov/points/' + latlong).json()['properties']['forecastHourly']
  f = session.get(url).json()['properties']
  print(f['periods'][0]['temperature'])
  print(f['generatedAt'])
That function shows the state of error handling in Go.
Uh, no, it's just bad code.

Don't get me wrong, error handling is verbose and annoying, but not even displaying actual error is just horrible coding practice.

should be at the very least

    err = json.Unmarshal(weatherBody, &WeatherRes)
    if err != nil {
        fmt.Printf("error decoding weather json: %s\n",err)
 return
    }
or just be function that returns that error or the weather

    err = json.Unmarshal(weatherBody, &WeatherRes)
    if err != nil {
 return fmt.Errorf("error decoding weather json: %s\n",err)
    }
wouldn't mind a question mark for checking nil err like result in rust..
I'd even settle for

    return err if err != nil
everything better than three fucking lines every time something returns err.

Especially that some clown decided that apparently

    if err != nil { return err }
is too terse and go fmt just goes back to expanding it to 3 lines...
What is an example of a better approach? Methods that throw exceptions?
I just don’t understand why this is better than returning an error to caller? E.g have an err return type that could be nil. This type of practice just seems to ask for undefined behavior or debugging frustration. when you finally track down this log statement, we have multiple call sites to choose from to determine where this free form log string came from. Hopefully the same generic string was not used in a separate function!
I use(d) ansiweather with geektool:

AnsiWeather is a Shell script for displaying the current weather conditions in your terminal, with support for ANSI colors and Unicode symbols. Weather data comes from the OpenWeatherMap free weather API.

AnsiWeather packages are available for: OpenBSD, NetBSD, FreeBSD, Debian, Ubuntu, Homebrew

https://github.com/fcambus/ansiweather

// Looking for geektool alternative for arm64 w/o Rosetta.

I prefer this one:

https://github.com/chubin/wttr.in

You gotta love terminal man!

Reminds me of `curl wttr.in` -- although slightly more verbose in some metrics.
I had the same thought; this is in my shell RC:

    alias weather='f() { curl wttr.in/${1:-sydney} };f'
Interesting -- why do you define an alias that defines and then immediately calls a function instead of just defining `weather` as the function itself?

         echo yourcity | nc graph.no 79
or

         finger yourcity@graph.no
You can also view the weather in the terminal with Curl using curl wttr.in
Getting the weather is one thing, but being to POST would be a game changer. Think of what it would do to help gardening
Some people just wanna watch the world DELETE
How does this compare to long standing CLI oriented web services like https://github.com/chubin/wttr.in ?
Can this be marked as a Show HN?
Or you can just use this and avoid installing a script to check the weather!

https://github.com/chubin/wttr.in

This is delightful! I really love how understated the README is “the cli tool that no one needs”, and also two DP on the temperature. I will clone and start using first thing in the morning. Thank you.
A small suggestion. I always add the expected output to a sample input in GitHub readme. I think it helps a lot to attract any prospective users.
wttr.in is pretty good, as it also doesn't require another program. But this is nice too.