Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added quick check for .weather file in home dir.

Got tired of typing zip.
  • Loading branch information...
commit ffaee6211e2c916f6ec516483dc36ff7982b43ff 1 parent 7e0d53b
John Nunemaker authored
Showing with 17 additions and 9 deletions.
  1. +17 −9 bin/weather
26 bin/weather
View
@@ -1,17 +1,25 @@
#!/usr/bin/env ruby
-
+require 'rubygems'
require File.dirname(__FILE__) + '/../lib/google_weather'
-if ARGV.size == 0
- puts 'Weather [Powered by Google]'
- puts 'USAGE: weather [zip code or city]'
- puts 'EXAMPLES:'
- puts ' weather 46544'
- puts ' weather "mishawaka, in"'
- exit
+path = Pathname(ENV["HOME"]).join('.weather')
+
+if path.exist? && ARGV.size == 0
+ param = path.read
+else
+ if ARGV.size == 0
+ puts 'Weather [Powered by Google]'
+ puts 'USAGE: weather [zip code or city]'
+ puts 'EXAMPLES:'
+ puts ' weather 46544'
+ puts ' weather "mishawaka, in"'
+ exit
+ end
+
+ param = ARGV[0]
end
-weather = GoogleWeather.new(ARGV[0])
+weather = GoogleWeather.new(param)
current = weather.current_conditions
puts
puts "#{weather.forecast_information.city}"
Please sign in to comment.
Something went wrong with that request. Please try again.