2009-10-01 23:22:47 -07:00
|
|
|
#!/usr/bin/env ruby
|
2010-02-11 21:41:37 -08:00
|
|
|
lib_dir = File.join(File.dirname(__FILE__), '..', 'lib')
|
|
|
|
require File.join(lib_dir, 'fog')
|
2009-10-01 23:22:47 -07:00
|
|
|
require 'irb'
|
|
|
|
require 'yaml'
|
|
|
|
|
2010-02-11 21:41:37 -08:00
|
|
|
require File.join(lib_dir, 'fog', 'bin')
|
2010-02-06 15:42:38 -08:00
|
|
|
|
2010-02-11 21:41:37 -08:00
|
|
|
Fog.credential = (ARGV.first && :"#{ARGV.first}") || :default
|
|
|
|
unless Fog.credentials
|
|
|
|
exit
|
2010-02-06 15:42:38 -08:00
|
|
|
end
|
|
|
|
|
2010-02-15 17:15:56 -08:00
|
|
|
require File.join(lib_dir, 'fog', 'aws', 'bin')
|
|
|
|
require File.join(lib_dir, 'fog', 'rackspace', 'bin')
|
|
|
|
require File.join(lib_dir, 'fog', 'slicehost', 'bin')
|
|
|
|
require File.join(lib_dir, 'fog', 'terremark', 'bin')
|
|
|
|
|
2009-10-01 23:22:47 -07:00
|
|
|
ARGV.clear # Avoid passing args to IRB
|
|
|
|
IRB.setup(nil)
|
|
|
|
@irb = IRB::Irb.new(nil)
|
|
|
|
IRB.conf[:MAIN_CONTEXT] = @irb.context
|
2010-02-14 14:34:33 -08:00
|
|
|
IRB.conf[:PROMPT][:FOG] = IRB.conf[:PROMPT][:SIMPLE].dup
|
|
|
|
IRB.conf[:PROMPT][:FOG][:RETURN] = "%s\n"
|
|
|
|
@irb.context.prompt_mode = :FOG
|
2009-10-01 23:22:47 -07:00
|
|
|
@irb.context.workspace = IRB::WorkSpace.new(binding)
|
2010-02-14 14:34:33 -08:00
|
|
|
|
2010-02-15 17:15:56 -08:00
|
|
|
services = Fog.services.map{|service| service.to_s}
|
|
|
|
available_services = if services.length > 1
|
|
|
|
services[0...-1].join(', ') << ' and ' << services[-1]
|
|
|
|
else
|
|
|
|
services.first
|
|
|
|
end
|
|
|
|
print "Welcome to fog interactive; your '#{Fog.credential.to_s}' configuration provides access to #{available_services}.\n"
|
2010-02-14 14:34:33 -08:00
|
|
|
|
2010-02-15 17:15:56 -08:00
|
|
|
catch(:IRB_EXIT) { @irb.eval_input }
|