Permalink
Browse files

Ability to skip referral queries in the command line

  • Loading branch information...
1 parent 07262e6 commit 73bf871ac56c5117b065657a27938bfdca3a1023 @weppos committed Nov 12, 2012
Showing with 8 additions and 5 deletions.
  1. +8 −5 bin/ruby-whois
View
@@ -3,11 +3,10 @@
$:.unshift(File.expand_path("../../lib", __FILE__))
require 'optparse'
-require 'ostruct'
require 'whois'
-options = OpenStruct.new
+options = {}
OptionParser.new do |opts|
opts.banner = "Whois: an intelligent pure Ruby Whois client"
opts.define_head "Usage: ruby-whois [options] object"
@@ -19,11 +18,15 @@ OptionParser.new do |opts|
opts.separator "Options:"
opts.on("-t", "--timeout [SECONDS]", Integer, "set the timeout") do |seconds|
- options.timeout = seconds
+ options[:timeout] = seconds
end
opts.on("-h", "--host [HOST]", String, "connect to server HOST") do |host|
- options.host = host
+ options[:host] = host
+ end
+
+ opts.on("--[no-]referral", "skip referral queries") do |boolean|
+ options[:referral] = boolean
end
opts.on_tail("--help", "show this help and exit") do
@@ -52,7 +55,7 @@ end
object = ARGV.shift
begin
- @client = Whois::Client.new(:timeout => options.timeout, :host => options.host)
+ @client = Whois::Client.new(options)
puts @client.query(object)
rescue Whois::Error => e
abort(e.message)

0 comments on commit 73bf871

Please sign in to comment.