#!/usr/bin/env ruby require 'rawler' require File.join(File.dirname(__FILE__), '..', '/vendor/lib-trollop.rb') opts = Trollop::options do version "rawler #{Rawler::VERSION} (c) 2011 Oscar Del Ben" banner <<-EOS Rawler is a command line utility for parsing links on a website Usage: rawler http://example.com [options] where [options] are: EOS opt :username, "HTTP Basic Username", :type => :string opt :password, "HTTP Basic Password", :type => :string opt :wait, "Seconds to wait between requests, may be fractional e.g. '1.5'", :type => :float, :default => 3.0 opt :log, "Log results to file #{Rawler::Base::DEFAULT_LOGFILE}", :type => :boolean, :default => false opt :logfile, "Specify logfile, implies --log", :type => :string, :default => Rawler::Base::DEFAULT_LOGFILE opt :css, "Check CSS links", :type => :boolean, :default => false opt :skip, "Skip URLs that match a pattern", :type => :string opt :iskip, "Skip URLs that match a case insensitive pattern", :type => :string opt :include, "Only include URLS that match a pattern", :type => :string opt :iinclude, "Only include URLS that match a case insensitive pattern. Equivalent to '--include ^http://mysite.com/*'.", :type => :string opt :local, "Restrict to the given URL and below", :type => :boolean, :default => false end domain = ARGV.shift if domain.nil? Trollop::die "Domain name is mandatory. Type --help for help" else Trollop::options do opt :domain, "Domain address", :type => :string end end Rawler::Base.new(domain, $stdout, opts).validate