Sha256: d610e61fa446a7fa93a7c05d55c926b7b2043c92ebd1e4f72070c106bab99167

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

module Imap::Backup
  class CLI::Restore < Thor
    include Thor::Actions
    include CLI::Helpers

    attr_reader :email
    attr_reader :options

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
imap-backup-10.0.0 lib/imap/backup/cli/restore.rb