#!/usr/bin/env ruby require 'pwhois' w = Pwhois::WhoisParser.new OptionParser.new do |opts| opts.banner = "Usage: #{opts.program_name} [options]" opts.separator "" opts.separator "Specific options:" opts.on("-v", "--[no-]verbose", "Run verbosely") do |v| w.verbose = v end output_list = Pwhois::OUTPUT_STYLES.join(', ') opts.on("-o", "--output TYPE", Pwhois::OUTPUT_STYLES, "Output style. One of: #{output_list}") do |style| w.output_style = style end opts.on("-a", "--attributes x,y,z", Array, "Attributes to return.") do |list| w.attributes = Array.new(list.map{ |i| i.to_sym }) if !w.attributes.include?(:domain) w.attributes.push(:domain) end w.attributes.freeze end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.on_tail("-V", "--version", "Show version") do puts Pwhois::VERSION exit end if ARGV.length == 0 puts "No domains given." puts opts exit end end.parse! w.query_list(ARGV)