Sha256: a55f3c2d1992a64a97ed8c5108b46575cfc58a45d0cfbcab725add39265a1d44

Contents?: true

Size: 1.15 KB

Versions: 41

Compression:

Stored size: 1.15 KB

Contents

#!/usr/bin/env ruby -wKU

$:.unshift(File.dirname(__FILE__) + "/../lib")

require 'optparse'
require 'ostruct'
require 'whois'


options = OpenStruct.new
OptionParser.new do |opts|
  opts.banner     = "Whois: an intelligent pure Ruby Whois client"
  opts.define_head  "Usage: whois [options] object"
  opts.separator    ""
  opts.separator    "Examples:"
  opts.separator    " whois ruby-lang.com"
  opts.separator    " whois 213.149.247.64"
  opts.separator    ""
  opts.separator    "Options:"

  opts.on("-t", "--timeout [SECONDS]", Integer, "Specify the timeout value") do |seconds|
    options.timeout = seconds
  end

  opts.on_tail("--help", "Show this message") do
    puts opts
    exit
  end

  opts.on_tail("-v", "--version", "Show version") do
    puts "#{Whois::NAME} #{Whois::VERSION}"
    exit
  end

  begin
    opts.parse!
  rescue OptionParser::ParseError
    puts opts
    exit 1
  end

  if ARGV.size.zero?
    puts opts
    exit 1
  end
end

qstring = ARGV.shift

begin
  @client = Whois::Client.new(:timeout => options.timeout)
  puts @client.query(qstring)
rescue Whois::Error => e
  abort(e.message)
rescue Timeout::Error => e
  abort("Request Timeout")
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
whois-1.6.1 bin/ruby-whois
whois-1.6.0 bin/ruby-whois
whois-1.5.1 bin/ruby-whois
whois-1.5.0 bin/ruby-whois
whois-1.3.11 bin/ruby-whois
whois-1.3.10 bin/ruby-whois
whois-1.3.9 bin/ruby-whois
whois-1.3.8 bin/ruby-whois
whois-1.3.7 bin/ruby-whois
whois-1.3.6 bin/ruby-whois
whois-1.3.5 bin/ruby-whois
whois-1.3.4 bin/ruby-whois
whois-1.3.3 bin/ruby-whois
whois-1.3.2 bin/ruby-whois
whois-1.3.1 bin/ruby-whois
whois-1.3.0 bin/ruby-whois
whois-1.2.2 bin/ruby-whois
whois-1.2.1 bin/ruby-whois
whois-1.2.0 bin/ruby-whois
whois-1.1.8 bin/ruby-whois