Sha256: 6a1f6eb2d5a4f50ba11e4c95b332c270329985f73682ca57ec653e455a55651f

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

#!/usr/bin/env ruby

require 'optparse'
require 'ostruct'

class OptionsParser
  def self.parse(args)
    options = OpenStruct.new
    options.google_website = "google.com.br"
    options.max_links = 100

    opt_parser = OptionParser.new do |opts|
      opts.banner = "Usage: email-crawler [options]"
      opts.separator ""

      opts.on("-q", '--query "SEARCH TERM/EXPRESSION"',
              "The term/expression you want to search for") do |q|
        options.q = q
      end

      opts.on("-g", "--google-website google.com.au",
              "An alternative Google website",
              "  (defaults to Google Brazil)") do |google_website|
        options.google_website = google_website
      end

      opts.on("-m", "--max-links 250",
              "Max # of internal links to visit searching for emails",
              "  (per search result, defaults to 100)") do |max_links|
        options.max_links = max_links.to_i
      end
    end

    opt_parser.parse!(args)
    options
  end
end

options = OptionsParser.parse(ARGV)
if options.q.empty?
  print "The -q switch is mandatory\n"
  exit(1)
else
  require_relative "../lib/email_crawler"
  csv = EmailCrawler::Runner.new(options.google_website).run(options.q, options.max_links)
  $stdout << "#{csv}\n"
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
email_crawler-0.0.4 bin/email-crawler
email_crawler-0.0.3 bin/email-crawler
email_crawler-0.0.2 bin/email-crawler