bin/kumogata in kumogata-0.4.4 vs bin/kumogata in kumogata-0.4.5

- old
+ new

@@ -1,9 +1,10 @@ #!/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 @@ -12,22 +13,22 @@ exit 1 end } begin - command, arguments, options = parsed + 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 = ($stdout.tty? and options.color?) - Diffy::Diff.default_format = ($stdout.tty? and options.color?) ? :color : :text + String.colorize = options.color? + Diffy::Diff.default_format = options.color? ? :color : :text if options.debug? Kumogata.logger.set_debug(true) AWS.config({ @@ -35,15 +36,24 @@ :logger => Kumogata.logger, }) end out = Kumogata::Client.new(options).send(command, *arguments) - puts out if out + + 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) + backtrace = backtrace.slice(0, 3) + unless backtrace.empty? + $stderr.puts " from #{backtrace.first}".red + end end exit 1 end