Sha256: d31dbdff778ce1a6289d29a018fbc5e1161abcd6fc08fca70cdfc757f54d9f85

Contents?: true

Size: 1.33 KB

Versions: 12

Compression:

Stored size: 1.33 KB

Contents

#!/usr/bin/env ruby

$:.unshift(File.expand_path("../../lib", __FILE__))

require 'optparse'
require 'whois'


options = {}
OptionParser.new do |opts|
  opts.banner     = "Whois: an intelligent pure Ruby WHOIS client"
  opts.define_head  "Usage: whoisrb [options] object"
  opts.separator    ""
  opts.separator    "Examples:"
  opts.separator    "\t whoisrb ruby-lang.com"
  opts.separator    "\t whoisrb 213.149.247.64"
  opts.separator    ""
  opts.separator    "Options:"

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

  opts.on("-h", "--host [HOST]", String, "connect to server HOST") do |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
    puts opts
    exit
  end

  opts.on_tail("--version", "output version information and exit") do
    puts "whoisrb #{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

object = ARGV.shift

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
whois-5.0.1 bin/whoisrb
whois-5.0.0 bin/whoisrb
whois-4.1.0 bin/whoisrb
whois-4.0.8 bin/whoisrb
whois-4.0.7 bin/whoisrb
whois-4.0.6 bin/whoisrb
whois-4.0.5 bin/whoisrb
whois-4.0.4 bin/whoisrb
whois-4.0.3 bin/whoisrb
whois-4.0.2 bin/whoisrb
whois-4.0.1 bin/whoisrb
whois-4.0.0 bin/whoisrb