lib/awskeyring_command.rb in awskeyring-0.10.0 vs lib/awskeyring_command.rb in awskeyring-1.0.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'i18n' require 'thor' require 'awskeyring' require 'awskeyring/awsapi' @@ -12,10 +14,11 @@ I18n.load_path = Dir.glob(File.join(File.realpath(__dir__), '..', 'i18n', '*.{yml,yaml}')) I18n.backend.load_translations map %w[--version -v] => :__version map ['init'] => :initialise + map ['adr'] => :add_role map ['con'] => :console map ['ls'] => :list map ['lsr'] => :list_role map ['rm'] => :remove map ['rmr'] => :remove_role @@ -25,11 +28,12 @@ map ['up'] => :update desc '--version, -v', I18n.t('__version.desc') # print the version number def __version - puts Awskeyring::VERSION + puts "Awskeyring v#{Awskeyring::VERSION}" + puts "Homepage #{Awskeyring::HOMEPAGE}" end desc 'initialise', I18n.t('initialise.desc') method_option :keychain, type: :string, aliases: '-n', desc: I18n.t('method_option.keychain') # initialise the keychain @@ -235,12 +239,12 @@ account: cred[:account], key: cred[:key], secret: cred[:secret], key_message: I18n.t('message.rotate', account: account) ) - rescue Aws::Errors::ServiceError => err - warn err.to_s + rescue Aws::Errors::ServiceError => e + warn e.to_s exit 1 end Awskeyring.update_account( account: account, @@ -289,12 +293,12 @@ key: item_hash[:key], secret: item_hash[:secret], user: ENV['USER'] ) Awskeyring.delete_token(account: account, message: '# Removing STS credentials') - rescue Aws::Errors::ServiceError => err - warn err.to_s + rescue Aws::Errors::ServiceError => e + warn e.to_s exit 1 end Awskeyring.add_token( account: account, @@ -327,12 +331,12 @@ secret: cred[:secret], token: cred[:token], path: path, user: ENV['USER'] ) - rescue Aws::Errors::ServiceError => err - warn err.to_s + rescue Aws::Errors::ServiceError => e + warn e.to_s exit 1 end if options['no-open'] puts login_url @@ -434,11 +438,11 @@ def ask_check(existing:, message:, secure: false, optional: false, validator: nil) retries ||= 3 begin value = ask_missing(existing: existing, message: message, secure: secure, optional: optional) value = validator.call(value) unless value.empty? && optional - rescue RuntimeError => err - warn err.message + rescue RuntimeError => e + warn e.message existing = nil retry unless (retries -= 1).zero? exit 1 end value