Sha256: c1c8bad21d64cd839870724f49ceb3e6a47ea83c4a97121541eadcc57beb3846

Contents?: true

Size: 1.75 KB

Versions: 65

Compression:

Stored size: 1.75 KB

Contents

#!/usr/bin/env ruby

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'fog'))
require 'optparse'
require 'irb'
require 'yaml'

options = OptionParser.new do |opts|
  opts.banner = 'usage: fog [options] CREDENTIAL'

  opts.on('-C', '--credentials-path FILE', 'Path to the credentials file') do |file|
    Fog.credentials_path = file
  end

  opts.on_tail('-v', '--version', 'Prints the version') do
    puts Fog::VERSION
    exit
  end

  opts.on_tail('-h', '--help', 'Prints this message') do
    puts opts
    exit
  end
end
options.parse!

Fog.credential = ARGV.first ? ARGV.first.to_sym : nil
Fog.mock! if ENV['FOG_MOCK']
if Fog.credentials.empty?
  begin
    Fog::Errors.missing_credentials
  rescue Fog::Errors::LoadError => error
    abort error.message
  end
end

require 'fog/bin'

providers = Fog.available_providers
providers = if providers.length > 1
  providers[0...-1].join(', ') << ' and ' << providers[-1]
else
  providers.first
end

if ARGV.length > 1

  result = instance_eval(ARGV[1..-1].join(' '))
  puts(Fog::JSON.encode(result))

else

  ARGV.clear # Avoid passing args to IRB
  IRB.setup(nil)
  @irb = IRB::Irb.new(nil)
  IRB.conf[:MAIN_CONTEXT] = @irb.context
  IRB.conf[:PROMPT][:FOG] = IRB.conf[:PROMPT][:SIMPLE].dup
  IRB.conf[:PROMPT][:FOG][:RETURN] = "%s\n"
  @irb.context.prompt_mode = :FOG
  @irb.context.workspace = IRB::WorkSpace.new(binding)

  trap 'INT' do
    @irb.signal_handle
  end

  Formatador.display_line('Welcome to fog interactive!')
  Formatador.display_line(":#{Fog.credential} provides #{providers}")
  providers = Fog.providers

  # FIXME: hacks until we can `include Fog` in bin
  CDN     = Fog::CDN
  Compute = Fog::Compute
  DNS     = Fog::DNS
  Storage = Fog::Storage

  catch(:IRB_EXIT) { @irb.eval_input }

end

Version data entries

65 entries across 65 versions & 6 rubygems

Version Path
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/bin/fog
fog-1.27.0 bin/fog
fog-1.26.0 bin/fog
fog-1.25.0 bin/fog
nsidc-fog-1.24.1 bin/fog
fog-1.24.0 bin/fog
ns-fog-1.22.11 bin/fog
ns-fog-1.22.10 bin/fog
ns-fog-1.22.9 bin/fog
ns-fog-1.22.8 bin/fog
ns-fog-1.22.7 bin/fog
ns-fog-1.22.6 bin/fog
fog-1.23.0 bin/fog
ns-fog-1.22.4 bin/fog
ns-fog-1.22.3 bin/fog
ns-fog-1.22.2 bin/fog
fog-1.22.1 bin/fog
fog-1.22.0 bin/fog
fog-1.21.0 bin/fog
fog-maestrodev-1.20.0.20140305101839 bin/fog