lib/awskeyring_command.rb in awskeyring-1.5.0 vs lib/awskeyring_command.rb in awskeyring-1.6.0
- old
+ new
@@ -70,18 +70,26 @@
end
desc 'list', I18n.t('list.desc')
# list the accounts
def list
+ if Awskeyring.list_account_names.empty?
+ warn I18n.t('message.missing_account', bin: File.basename($PROGRAM_NAME))
+ exit 1
+ end
puts Awskeyring.list_account_names.join("\n")
end
map 'list-role' => :list_role
desc 'list-role', I18n.t('list_role.desc')
method_option 'detail', type: :boolean, aliases: '-d', desc: I18n.t('method_option.detail'), default: false
# List roles
def list_role
+ if Awskeyring.list_role_names.empty?
+ warn I18n.t('message.missing_role', bin: File.basename($PROGRAM_NAME))
+ exit 1
+ end
if options['detail']
puts Awskeyring.list_role_names_plus.join("\n")
else
puts Awskeyring.list_role_names.join("\n")
end
@@ -537,26 +545,26 @@
existing || ask(message: message, secure: secure, optional: optional, limited_to: limited_to).strip
end
def ask(message:, secure: false, optional: false, limited_to: nil)
if secure
- Awskeyring::Input.read_secret(message.rjust(20) + ': ')
+ Awskeyring::Input.read_secret("#{message.rjust(20)}: ")
elsif optional
- Thor::LineEditor.readline((message + ' (optional)').rjust(20) + ': ')
+ Thor::LineEditor.readline("#{"#{message} (optional)".rjust(20)}: ")
elsif limited_to
- Thor::LineEditor.readline(message.rjust(20) + ': ', limited_to: limited_to)
+ Thor::LineEditor.readline("#{message.rjust(20)}: ", limited_to: limited_to)
else
- Thor::LineEditor.readline(message.rjust(20) + ': ')
+ Thor::LineEditor.readline("#{message.rjust(20)}: ")
end
end
def unbundle
to_delete = ENV.keys.select { |elem| elem.start_with?('BUNDLER_ORIG_') }
- bundled_env = to_delete.map { |elem| elem[('BUNDLER_ORIG_'.length)..-1] }
+ bundled_env = to_delete.map { |elem| elem[('BUNDLER_ORIG_'.length)..] }
to_delete << 'BUNDLE_GEMFILE'
bundled_env.each do |env_name|
- ENV[env_name] = ENV['BUNDLER_ORIG_' + env_name]
- to_delete << env_name if ENV['BUNDLER_ORIG_' + env_name].start_with? 'BUNDLER_'
+ ENV[env_name] = ENV["BUNDLER_ORIG_#{env_name}"]
+ to_delete << env_name if ENV["BUNDLER_ORIG_#{env_name}"].start_with? 'BUNDLER_'
end
to_delete.each do |env_name|
ENV.delete(env_name)
end
end