Class: Imap::Backup::CLI::Restore

Inherits:
Thor
  • Object
show all
Includes:
Helpers, Thor::Actions
Defined in:
lib/imap/backup/cli/restore.rb

Overview

Restores backups for one or more accounts

Instance Method Summary collapse

Methods included from Helpers

#account, included, #load_config, #requested_accounts

Constructor Details

#initialize(email = nil, options) ⇒ Restore

Returns a new instance of Restore.



17
18
19
20
21
# File 'lib/imap/backup/cli/restore.rb', line 17

def initialize(email = nil, options)
  super([])
  @email = email
  @options = options
end

Instance Method Details

#runvoid

This method returns an undefined value.

Raises:

  • (RuntimeError)

    if no email is specified



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/imap/backup/cli/restore.rb', line 26

no_commands do
  def run
    config = load_config(**options)
    case
    when email && !options.key?(:accounts)
       = (config, email)
      restore(, **restore_options)
    when !email && !options.key?(:accounts)
      Logger.logger.info "Calling restore without an EMAIL parameter is deprecated"
      config.accounts.each { |a| restore(a) }
    when email && options.key?(:accounts)
      raise "Missing EMAIL parameter"
    when !email && options.key?(:accounts)
      Logger.logger.info(
        "Calling restore with the --account option is deprecated, " \
        "please pass a single EMAIL parameter"
      )
      requested_accounts(config).each { |a| restore(a) }
    end
  end
end