def get_options(args)
options = DEFAULT_OPTIONS
status = 0
parser = OptionParser.new do |opts|
opts.banner = "Usage: #{$0} proxy [options]"
opts.separator ""
opts.separator "Specific options:"
opts.on("-h","--host", "=IP_ADDRESS", "IP address to listen on. Default: binds to all IP addresses of the computer") do |arg|
options[:host] = arg
end
opts.on("-p","--port", "=PORT_NUMBER", Integer, "TCP port to listen on. Default port: #{DatabaseProxy::DEFAULT_PORT}") do |arg|
options[:port] = arg
end
opts.on_tail("--help", "Show this message") do
$stderr.puts opts
options = nil
end
end
begin
parser.parse!(args)
rescue Exception => e
$stderr.puts "Command line parsing failed: #{e}"
$stderr.puts parser.help
options = nil
status = 1
end
return options, status
end