#!/usr/bin/env ruby # -*- coding: utf-8 -*- require 'rubygems' $:.unshift File.expand_path '../lib', File.dirname(__FILE__) require 'weather-report' require 'optparse' require 'ostruct' options = OpenStruct.new opt_parser = OptionParser.new do |opts| opts.banner = 'Usage: weather-report CITY [options]' opts.separator "" opts.separator "Common options:" opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.on_tail("-v", "--version", "Show version") do puts "weather-report v#{WeatherReport::VERSION}" exit end end if ARGV.empty? puts opt_parser.help exit 1 end city = opt_parser.parse(ARGV) weather = WeatherReport::Weather.new(WeatherReport::Weather.request_cityid(*city)) [weather.today, weather.tomorrow, weather.day_after_tomorrow].each do |day| 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 end puts weather.link