Sha256: 48ae5804bd6fd9df35de6619f28fad8cbdba67c3bfd817e3911667debbfb4140

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

#!/usr/bin/env ruby
$: << File.expand_path("#{File.dirname __FILE__}/../lib")
require 'rubygems'
require 'kumogata'
require 'kumogata/argument_parser'

options = nil

parsed = Kumogata::ArgumentParser.parse! {|parser, cmd, args, opts|
  if (opts.access_key_id? and not opts.secret_access_key?) or
     (not opts.access_key_id? and opts.secret_access_key?)
    puts parser.help
    exit 1
  end
}

begin
  command, arguments, options, output_result = parsed

  aws_opts = {}

  [:access_key_id, :secret_access_key, :region].each do |key|
    aws_opts[key] = options[key] if options[key]
  end

  AWS.config(aws_opts) unless aws_opts.empty?

  String.colorize = options.color?
  Diffy::Diff.default_format = options.color? ? :color : :text

  if options.debug?
    Kumogata.logger.set_debug(true)

    AWS.config({
      :http_wire_trace => true,
      :logger => Kumogata.logger,
    })
  end

  out = Kumogata::Client.new(options).send(command, *arguments)

  if output_result and out
    puts out
  end
rescue Exception => e
  $stderr.puts("[ERROR] #{e.message}".red) unless e.kind_of?(Interrupt)

  if options and options.debug?
    raise e
  else
    backtrace = Kumogata::Utils.filter_backtrace(e.backtrace)

    unless backtrace.empty?
      $stderr.puts "  from #{backtrace.first}".red
    end
  end

  exit 1
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kumogata-0.4.8 bin/kumogata
kumogata-0.4.7 bin/kumogata
kumogata-0.4.6 bin/kumogata