Class: Imap::Backup::CLI

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

Defined Under Namespace

Modules: Helpers Classes: Backup, FolderEnumerator, Local, Migrate, Mirror, Remote, Restore, Setup, Stats, Utils

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#account, #connection, #each_connection, included, #load_config, #options

Class Method Details

.accounts_optionObject



44
45
46
47
48
49
50
51
# File 'lib/imap/backup/cli.rb', line 44

def self.accounts_option
  method_option(
    "accounts",
    type: :string,
    desc: "a comma-separated list of accounts (defaults to all configured accounts)",
    aliases: ["-a"]
  )
end

.exit_on_failure?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/imap/backup/cli.rb', line 40

def self.exit_on_failure?
  true
end

.start(*args) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/imap/backup/cli.rb', line 25

def self.start(*args)
  # By default, commands like `imap-backup help foo bar`
  # are handled by listing all `foo` methods, whereas the user
  # probably wants the detailed help for the `bar` method.
  # Move initial "help" argument to after any subcommand,
  # so we get help for the requested subcommand method.
  first_argument_is_help = ARGV[0] == "help"
  second_argument_is_subcommand = subcommands.include?(ARGV[1])
  if first_argument_is_help && second_argument_is_subcommand
    help, subcommand = ARGV.shift(2)
    ARGV.unshift(subcommand, help)
  end
  super
end

Instance Method Details

#backupObject



71
72
73
74
# File 'lib/imap/backup/cli.rb', line 71

def backup
  non_logging_options = Imap::Backup::Logger.setup_logging(options)
  Backup.new(non_logging_options).run
end

#migrate(source_email, destination_email) ⇒ Object



128
129
130
131
# File 'lib/imap/backup/cli.rb', line 128

def migrate(source_email, destination_email)
  non_logging_options = Imap::Backup::Logger.setup_logging(options)
  Migrate.new(source_email, destination_email, **non_logging_options).run
end

#mirror(source_email, destination_email) ⇒ Object



178
179
180
181
# File 'lib/imap/backup/cli.rb', line 178

def mirror(source_email, destination_email)
  non_logging_options = Imap::Backup::Logger.setup_logging(options)
  Mirror.new(source_email, destination_email, **non_logging_options).run
end

#restore(email = nil) ⇒ Object



195
196
197
198
# File 'lib/imap/backup/cli.rb', line 195

def restore(email = nil)
  non_logging_options = Imap::Backup::Logger.setup_logging(options)
  Restore.new(email, non_logging_options).run
end

#setupObject



208
209
210
211
# File 'lib/imap/backup/cli.rb', line 208

def setup
  non_logging_options = Imap::Backup::Logger.setup_logging(options)
  Setup.new(non_logging_options).run
end

#stats(email) ⇒ Object



223
224
225
226
# File 'lib/imap/backup/cli.rb', line 223

def stats(email)
  non_logging_options = Imap::Backup::Logger.setup_logging(options)
  Stats.new(email, non_logging_options).run
end