Class: Imap::Backup::CLI::Backup
- Inherits:
-
Thor
- Object
- Thor
- Imap::Backup::CLI::Backup
- Includes:
- Helpers, Thor::Actions
- Defined in:
- lib/imap/backup/cli/backup.rb
Overview
Runs backups of configured accounts
Instance Method Summary collapse
-
#initialize(options) ⇒ Backup
constructor
A new instance of Backup.
- #run ⇒ void
Methods included from Helpers
#account, included, #load_config, #requested_accounts
Constructor Details
#initialize(options) ⇒ Backup
Returns a new instance of Backup.
18 19 20 21 |
# File 'lib/imap/backup/cli/backup.rb', line 18 def initialize() super([]) @options = end |
Instance Method Details
#run ⇒ void
This method returns an undefined value.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/imap/backup/cli/backup.rb', line 25 no_commands do def run config = load_config(**) exit_code = nil accounts = requested_accounts(config) if accounts.none? Logger.logger.warn "No matching accounts found to backup" return end accounts.each do |account| backup = Account::Backup.new(account: account, refresh: refresh) backup.run rescue StandardError => e exit_code ||= choose_exit_code(e) = <<~ERROR Backup for account '#{account.username}' failed with error #{e} #{e.backtrace.join("\n")} ERROR Logger.logger.error next end exit(exit_code) if exit_code end end |