Sha256: 880e9b6a0a3d685af4d448065a4881e9658af7c578a68f1195136d2a79392be6

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

#!/usr/bin/env ruby 

$:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')

require "s3ranger/exceptions"
require "s3ranger/config"
require "s3ranger/cli"

conf = S3Ranger::Config.new

# Time to load config and see if we've got everything we need to cook our salad
begin
  conf.read
rescue S3Ranger::NoConfigFound => exc
  # We can't proceed without having those two vars set
  if not (conf.has_key? "AWS_ACCESS_KEY_ID" and conf.has_key? "AWS_SECRET_ACCESS_KEY")
    $stderr.puts "You didn't set up your environment variables :("
    $stderr.puts "I tried the following paths:"
    exc.paths_checked.each {|path| $stderr.puts " * #{path}/s3config.yml"}

    $stderr.puts "You could try to set the `S3CONF' environment variable."
    $stderr.puts "Learn how to do that here: https://github.com/clarete/s3ranger"
    exit
  end
end

# Step aside, the star of this show is here. Let's try to create the
# environment to run the requested command. And feed the user back if
# information needed was not enough
begin
  S3Ranger::CLI::run conf
rescue S3Ranger::FailureFeedback => exc
  $stderr.puts exc.message
  exit 1
rescue S3Ranger::WrongUsage => exc
  name = $0.split('/').last
  $stderr.puts "Error:\n  #{exc.msg}\n" if exc.msg
  exit exc.error_code
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
s3ranger-0.2.1 bin/s3ranger
s3ranger-0.2.0 bin/s3ranger