#!/usr/bin/env ruby require 'rubygems' require 'controller' require 'provider' require 'optparse' options = {} optparse = OptionParser.new do |opts| opts.banner = "Usage: provider -d DRIVER [options]" opts.separator "" opts.separator "Basic Options:" opts.on("-d", "--driver TYPE", "Specify driver type to use on this provider:", " - watir", " - webdriver", " - selenium", " - firewatir", " - safariwatir") do |d| options[:driver] = d end opts.on("-c", "--controller URI", "Specify the controller URI to register this provider on e.g.:", " - druby://127.0.0.1:11235") do |c| options[:controller_uri] = c || nil end opts.on("-b", "--browser TYPE", "Specify the browser type to start when using webdriver or selenium:", " - firefox", " - chrome", " - ie") do |b| options[:browser_type] = b || nil end opts.separator "" opts.separator "Advanced Options:" opts.on("-h", "--drb HOST", "Specify the DRb host for this provider to bind to.") do |h| options[:drb_server_host] = h || nil end opts.on("-p", "--drb-port PORT", "Specify the DRb port for this provider to listen on.") do |p| options[:drb_server_port] = p end opts.on("-H", "--ring-server HOST", "Optionally specify the ring server host if not using controller URI.") do |h| options[:ring_server_host] = h || nil end opts.on("-P", "--ring-server-port PORT", "Optionally specify the ring server port if not using controller URI.") do |p| options[:ring_server_port] = p end opts.on("-a", "--access-control-list ACL", Array, "Specify a comma separated Access Control List.") do |a| options[:acls] = a end opts.on("-l", "--log LEVEL", "Specify the logging level:", " - DEBUG", " - INFO", " - ERROR") do |l| case l when 'DEBUG' options[:loglevel] = Logger::DEBUG when 'INFO' options[:loglevel] = Logger::INFO when 'ERROR' options[:loglevel] = Logger::ERROR else options[:loglevel] = Logger::ERROR end end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end end begin optparse.parse! mandatory = [:driver] missing = mandatory.select{ |param| options[param].nil? } if not missing.empty? puts "Missing options: #{missing.join(', ')}" puts optparse exit end rescue OptionParser::InvalidOption, OptionParser::MissingArgument puts $!.to_s puts optparse exit end provider = Provider.new( :drb_server_host => options[:drb_server_host], :drb_server_port => options[:drb_server_port] || 11236, :ring_server_host => options[:ring_server_host], :ring_server_port => options[:ring_server_port] || 12358, :driver => options[:driver] || nil, :browser_type => options[:browser_type] || nil, :controller_uri => options[:controller_uri] || nil, :acls => options[:acls] || %w{ allow all }, :loglevel => options[:loglevel]) provider.start DRb.thread.join