#!/usr/bin/env ruby $: << File.expand_path("#{File.dirname __FILE__}/../lib") require 'rubygems' require 'kumogata' options = nil begin 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 } command, arguments, options = 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? 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) puts out if out rescue => e $stderr.puts("[ERROR] #{e.message}".red) if options and options.debug? raise e end exit 1 end