#!/usr/bin/env ruby require 'rubygems' require 'grid' require 'optparse' options = {} OptionParser.new do |opts| opts.banner = "Usage: grid [options] command" opts.separator "" opts.separator "Commands:" opts.separator " list - List all grids" opts.separator " show - Show specified grids" opts.separator " create - Create a new grid" opts.separator " add - Add intranode to specified grid ID" opts.separator " delete - Delete intranode from specified grid ID" opts.separator " start - Start specified grid ID" opts.separator " stop - Stop specified grid ID" opts.separator " restart - Restart specified grid ID" opts.separator " status - Update status of specified grid ID" opts.separator "" opts.separator "Options:" opts.on("-g", "--grid ID", String, "Specify the Grid ID to use") do |g| options[:grid_id] = g || nil end opts.on("-t", "--token TOKEN", String, "Specify the token to authenticate with") do |t| options[:token] = t || nil end opts.on("-e", "--email EMAIL", String, "Specify the email to authenticate with, if not using token") do |e| options[:email] = e || nil end opts.on("-p", "--password PASSWORD", String, "Specify the password to authenticate with, if not using token") do |p| options[:password] = p || nil end opts.on("-u", "--uri URI", String, "Optional URI of the Gridinit API, default http://gridin.it/api/v0") do |u| options[:uri] = u || nil end opts.on("-a", "--api API", String, "Specify the Watir API to use, default webdriver [watir, firewatir, webdriver_performance]}") do |a| options[:api] = b || 'webdriver' end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end end.parse! helper = Grid::Helper.new( :grid_id => options[:grid_id], :token => options[:token], :email => options[:email], :password => options[:password], :uri => options[:uri], :api => options[:api], :args => ARGV ) helper.send(ARGV[0])