lib/conjur/cli.rb in conjur-cli-2.1.9 vs lib/conjur/cli.rb in conjur-cli-2.2.1

- old
+ new

@@ -17,28 +17,29 @@ end end end end - load_config - - ENV['CONJUR_ENV'] = Config[:env] || "production" - ENV['CONJUR_STACK'] = Config[:stack] if Config[:stack] - ENV['CONJUR_STACK'] ||= 'v3' if ENV['CONJUR_ENV'] == 'production' - ENV['CONJUR_ACCOUNT'] = Config[:account] or raise "Missing configuration setting: account. Please set it in ~/.conjurrc" - Conjur::Config.plugins.each do |plugin| - require "conjur-asset-#{plugin}" - end - commands_from 'conjur/command' - if Conjur.log - Conjur.log << "Using host #{Conjur::Authn::API.host}\n" - end - pre do |global,command,options,args| + load_config + + ENV['CONJUR_ENV'] = Config[:env] || "production" + ENV['CONJUR_STACK'] = Config[:stack] if Config[:stack] + ENV['CONJUR_STACK'] ||= 'v3' if ENV['CONJUR_ENV'] == 'production' + ENV['CONJUR_ACCOUNT'] = Config[:account] or raise "Missing configuration setting: account. Please set it in ~/.conjurrc" + + Conjur::Config.plugins.each do |plugin| + require "conjur-asset-#{plugin}" + end + + if Conjur.log + Conjur.log << "Using host #{Conjur::Authn::API.host}\n" + end + require 'active_support/core_ext' options.delete_if{|k,v| v.blank?} options.symbolize_keys! if as_group = options.delete(:"as-group") @@ -55,12 +56,10 @@ true end on_error do |exception| - if exception.is_a?(GLI::StandardException) - # pass - elsif exception.is_a?(RestClient::Exception) + if exception.is_a?(RestClient::Exception) begin body = JSON.parse(exception.response.body) $stderr.puts body['error'] rescue $stderr.puts exception.response.body if exception.response