#!/usr/bin/env ruby $:.unshift(File.join(File.dirname(__FILE__), "..", "lib")) require "poolparty" require "poolpartycl" name = ARGV.select {|arg| arg if Binary.available_binaries_for("cloud").include?(arg) }.first # If the options include -h and they don't include a valid command, then we can just pass the # original options back, but if they do contain a binary, we don't want -h getting through to # these options, so we'll strip it if it's included DUP_ARG = ARGV.dup new_args = DUP_ARG.reject {|arg| Binary.available_binaries_for("cloud").include?(arg) }.empty? ? ARGV : (name ? (DUP_ARG.delete("-h"); DUP_ARG) : DUP_ARG) # Let's make sure if no command is passed in that we show the help message new_args.push("-h") unless name o = PoolParty::Optioner.new(new_args, {:extra_help => "\nCloud actions\n#{Binary.list_binaries_for("cloud")}\n\n", :abstract => true}) do |opts, optioner| opts.on('-n cloudname', '--name name', 'Address this cloud') { |c| optioner.cloudname c } end program_name = "#{File.basename($0)}-#{name}" program_location = File.join(Binary.binary_directory, program_name) command_line = "#{program_location}" # Run it from the command-line first if Binary.available_binaries_for("cloud").include?(name) system command_line, *ARGV else puts "Unknown poolparty binary: #{name}" end