Sha256: 272844728fe404d1c38b95b05635c26f2bdd5d6fee71c01879b1a3a7c648efc8

Contents?: true

Size: 798 Bytes

Versions: 7

Compression:

Stored size: 798 Bytes

Contents

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

    attr_reader :options

    def initialize(options)
      super([])
      @options = options
    end

    no_commands do
      def run
        config = load_config(**options)
        each_connection(config, emails) do |connection|
          connection.run_backup(refresh: refresh)
        rescue StandardError => e
          message =
            "Backup for account '#{connection.account.username}' " \
            "failed with error #{e}"
          Logger.logger.warn message
          next
        end
      end

      def emails
        (options[:accounts] || "").split(",")
      end

      def refresh
        options.key?(:refresh) ? !!options[:refresh] : false
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
imap-backup-9.3.2 lib/imap/backup/cli/backup.rb
imap-backup-9.4.0.pre1 lib/imap/backup/cli/backup.rb
imap-backup-9.3.1 lib/imap/backup/cli/backup.rb
imap-backup-9.3.0 lib/imap/backup/cli/backup.rb
imap-backup-9.2.0 lib/imap/backup/cli/backup.rb
imap-backup-9.1.1 lib/imap/backup/cli/backup.rb
imap-backup-9.1.0 lib/imap/backup/cli/backup.rb