lib/imap/backup/cli/helpers.rb in imap-backup-4.0.7 vs lib/imap/backup/cli/helpers.rb in imap-backup-4.1.1

- old
+ new

@@ -1,15 +1,16 @@ require "imap/backup" +require "imap/backup/cli/accounts" module Imap::Backup::CLI::Helpers def symbolized(options) options.each.with_object({}) { |(k, v), acc| acc[k.intern] = v } end def account(email) - connections = Imap::Backup::Configuration::List.new - account = connections.accounts.find { |a| a.username == email } + accounts = Imap::Backup::CLI::Accounts.new + account = accounts.find { |a| a.username == email } raise "#{email} is not a configured account" if !account account end @@ -18,16 +19,14 @@ Imap::Backup::Account::Connection.new(account) end def each_connection(names) - begin - connections = Imap::Backup::Configuration::List.new(names) - rescue Imap::Backup::ConfigurationNotFound - raise "imap-backup is not configured. Run `imap-backup setup`" - end + accounts = Imap::Backup::CLI::Accounts.new(names) - connections.each_connection do |connection| - yield connection + accounts.each do |account| + yield account.connection end + rescue Imap::Backup::ConfigurationNotFound + raise "imap-backup is not configured. Run `imap-backup setup`" end end