Skip to content

Instantly share code, notes, and snippets.

@takkaw
Created August 9, 2009 02:47
Show Gist options
  • Select an option

  • Save takkaw/164586 to your computer and use it in GitHub Desktop.

Select an option

Save takkaw/164586 to your computer and use it in GitHub Desktop.
require 'open-uri'
require 'optparse'
url = 'http://www.ietf.org/rfc/'
pager = ENV['PAGER'] || 'less'
force_get = false
opts = OptionParser.new
opts.on("-f"){ force_get = true }
opts.parse!(ARGV)
rfc = "rfc" + ARGV.shift + ".txt"
get = false
get = true unless File.exist? rfc
get = true if force_get
if get
File.open(rfc,'w') { |f|
f.write open(url+rfc,'r').read
}
end
system "#{pager} #{rfc}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment