Sha256: 8b3577aac1538592ef27da74b20d14b71789355de7a1f1345c34bfcc23765030

Contents?: true

Size: 1.67 KB

Versions: 3

Compression:

Stored size: 1.67 KB

Contents

#!/usr/bin/env ruby

$:.unshift File.join(File.dirname(__FILE__), %w{.. lib})
require 'globetrotter'
require 'optparse'
require 'ostruct'

class GlobetrotterOptions
  def self.parse(args)
    options = OpenStruct.new
    options.domain = 'googleapis.com'
    options.ns_count_to_check = 100
    options.ns_max_age_minutes = 60
    options.timeout_seconds = 2
    options.ns_query_concurrency = 10
    options.file = false

    opt_parser = OptionParser.new do |opts|
      opts.banner = 'Usage: globetrotter [options] example.org'
      opts.on('-q googleapis.com', String, 'Domain to look up') do |o|
        options.domain = o
      end
      opts.on('-n 100', Integer, 'Query N name servers') do |o|
        options.ns_count_to_check = o
      end
      opts.on('-t 2', Integer, 'Wait T seconds per request') do |o|
        options.timeout_seconds = o
      end
      opts.on('-p 10', Integer, 'Query P name servers in parallel') do |o|
        options.ns_query_concurrency = o
      end
      opts.on('-a 60', Integer, 'Use name servers checked less than A minutes ago') do |o|
        options.ns_max_age_minutes = o
      end
      opts.on('-f /path/to/file', String, 'Read/write data to this file') do |o|
        options.file = o
      end
      opts.on_tail('-h', '--help', 'Display CLI help (this output)') do |o|
        puts opts.help
        exit
      end
      opts.on_tail('-v', '--version', 'Display Globetrotter version') do |o|
        puts "Globetrotter #{Globetrotter::VERSION}"
        exit
      end
    end # opt_parser

    opt_parser.parse!(args)

    options
  end # parse()
end # class Globetrotter Options

options = GlobetrotterOptions.parse(ARGV)
gt = Globetrotter.new(options)
gt.run

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
globetrotter-0.0.12 bin/globetrotter
globetrotter-0.0.11 bin/globetrotter
globetrotter-0.0.10 bin/globetrotter