Class: Imap::Backup::CLI
- Inherits:
-
Thor
- Object
- Thor
- Imap::Backup::CLI
- Includes:
- Helpers
- Defined in:
- lib/imap/backup/cli.rb,
lib/imap/backup/cli/local.rb,
lib/imap/backup/cli/setup.rb,
lib/imap/backup/cli/utils.rb,
lib/imap/backup/cli/backup.rb,
lib/imap/backup/cli/remote.rb,
lib/imap/backup/cli/single.rb,
lib/imap/backup/cli/helpers.rb,
lib/imap/backup/cli/options.rb,
lib/imap/backup/cli/restore.rb,
lib/imap/backup/cli/local/check.rb,
lib/imap/backup/cli/single/backup.rb
Overview
Top-level cli call handler
Defined Under Namespace
Modules: Helpers Classes: Backup, Local, Options, Remote, Restore, Setup, Single, Stats, Transfer, Utils
Class Method Summary collapse
-
.exit_on_failure? ⇒ Boolean
see Thor documentation.
-
.start(args) ⇒ void
Overrides Thor’s method to handle ‘–version’ and rearrange parameters if ‘help’ is passed.
Instance Method Summary collapse
-
#backup ⇒ void
Runs account backups.
-
#migrate(source_email, destination_email) ⇒ void
Migrates emails from one account to another.
-
#mirror(source_email, destination_email) ⇒ void
Keeps one email account in line with another.
-
#restore(email = nil) ⇒ void
Restores backed up emails to an account.
-
#setup ⇒ void
Runs the menu-driven setup program.
-
#stats(email) ⇒ void
Prints various statistics about a configured account.
-
#version ⇒ void
Prints the program version.
Methods included from Helpers
#account, included, #load_config, #options, #requested_accounts
Class Method Details
.exit_on_failure? ⇒ Boolean
73 74 75 |
# File 'lib/imap/backup/cli.rb', line 73 def self.exit_on_failure? true end |
.start(args) ⇒ void
This method returns an undefined value.
Overrides Thor’s method to handle ‘–version’ and rearrange parameters if ‘help’ is passed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/imap/backup/cli.rb', line 52 def self.start(args) if args.include?("--version") new.version exit 0 end # 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
#backup ⇒ void
This method returns an undefined value.
Runs account backups
92 93 94 95 |
# File 'lib/imap/backup/cli.rb', line 92 def backup = Imap::Backup::Logger.setup_logging() Backup.new().run end |
#migrate(source_email, destination_email) ⇒ void
This method returns an undefined value.
Migrates emails from one account to another
154 155 156 157 |
# File 'lib/imap/backup/cli.rb', line 154 def migrate(source_email, destination_email) = Imap::Backup::Logger.setup_logging() Transfer.new(:migrate, source_email, destination_email, ).run end |
#mirror(source_email, destination_email) ⇒ void
This method returns an undefined value.
Keeps one email account in line with another
215 216 217 218 |
# File 'lib/imap/backup/cli.rb', line 215 def mirror(source_email, destination_email) = Imap::Backup::Logger.setup_logging() Transfer.new(:mirror, source_email, destination_email, ).run end |
#restore(email = nil) ⇒ void
This method returns an undefined value.
Restores backed up emails to an account
245 246 247 248 |
# File 'lib/imap/backup/cli.rb', line 245 def restore(email = nil) = Imap::Backup::Logger.setup_logging() Restore.new(email, ).run end |
#setup ⇒ void
This method returns an undefined value.
Runs the menu-driven setup program
260 261 262 263 |
# File 'lib/imap/backup/cli.rb', line 260 def setup = Imap::Backup::Logger.setup_logging() CLI::Setup.new().run end |