#!/usr/bin/env ruby require 'bundler/setup' require 'weather-report' require 'slop' opts = Slop.parse(help: true) do banner 'Usage: weather-report CITY [options]' separator "" separator "Common options:" on :l, :list, 'Show city list' do WeatherReport.cities.each do |city| puts city end exit end on :v, :version, "Show version" do puts "weather-report v#{WeatherReport::VERSION}" exit end end exit if opts.help? if ARGV.empty? puts opts.help exit end city = ARGV weather = WeatherReport::Weather.new(WeatherReport::Weather.request_cityid(*city)) [weather.today, weather.tomorrow, weather.day_after_tomorrow].each do |day| begin print "#{day.date.year}年#{day.date.month}月#{day.date.day}日の天気 #{day.telop}" print " 最低気温#{day.temperature_min}度" if day.temperature_min print " 最高気温#{day.temperature_max}度" if day.temperature_max puts rescue NoMethodError next end end puts weather.link