Skip to content

Commit

Permalink
cleanup options/help
Browse files Browse the repository at this point in the history
Cleaned up options to make help more useful and throw errors when options don't make sense
  • Loading branch information
Robert Corsaro committed Oct 16, 2008
1 parent 90680cd commit 9d9e713
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions bin/mouseHole
Expand Up @@ -40,33 +40,37 @@ opts = OptionParser.new do |opts|
options.mouse_dir = d
end

=begin
opts.on("-s", "--server SERVER_APP",
"Web server to launch: mongrel, lighttpd or apache2 (default is mongrel)") do |s|
options.server = s
end
=end

opts.on("-D", "--[no-]daemon", "Daemon mode") do |d|
options.daemon = d
end

=begin
opts.on("-t", "--[no-]tidy", "Use Tidy?") do |t|
options.tidy = t
end
=end

opts.on("-v", "--verbose", "Run verbosely") do |v|
options.log_level = Logger::INFO
opts.on("-n", "--[no-]dnsruby", "Replace default ruby dns impl with dnsruby if installed. This solves a lot of timeout issues.") do |v|
options.dnsruby = v
end

opts.on("--log filename", "Log to a file (defaults to '-' which is STDOUT)") do |l|
options.server_log = l
opts.on("-v", "--verbose", "Run verbosely. Sets log level to INFO.") do |v|
options.verbose = Logger::INFO
end
opts.on("--debug", "Run with debugging data (proxy details, SQL queries)") do |v|
options.log_level = Logger::DEBUG

opts.on("--debug", "Run with debugging data (proxy details, SQL queries). Sets log level to DEBUG.") do |v|
options.debug = Logger::DEBUG
end

opts.on("--dnsruby", "Replace default ruby dns impl with dnsruby if installed. This solves a lot of timeout issues.") do |v|
options.dnsruby = v
opts.on("--log filename", "Log to a file (defaults to '-' which is STDOUT)") do |l|
options.server_log = l
end

opts.separator ""
Expand All @@ -87,16 +91,16 @@ opts = OptionParser.new do |opts|
end

opts.parse! ARGV
if options.verbose and options.debug
raise "ERROR: Choose debug or verbose, not both."
end
options.log_level = options.verbose || options.debug || options.log_level
options.host = ARGV[0] || "0.0.0.0"
options.port = ARGV[1] || 3704

if options.dnsruby
begin
require 'dnsruby'
Resolv = Dnsruby::Resolv
rescue
abort 'dnsruby is not installed'
end
require 'dnsruby'
Resolv = Dnsruby::Resolv
end

proxy_uri = nil
Expand Down

0 comments on commit 9d9e713

Please sign in to comment.