imap-backup 7.0.2 → 8.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/docs/configuration.md +3 -1
- data/lib/imap/backup/account/connection.rb +0 -8
- data/lib/imap/backup/cli/backup.rb +12 -5
- data/lib/imap/backup/cli/folders.rb +9 -3
- data/lib/imap/backup/cli/helpers.rb +36 -10
- data/lib/imap/backup/cli/local.rb +12 -7
- data/lib/imap/backup/cli/migrate.rb +5 -1
- data/lib/imap/backup/cli/mirror.rb +6 -2
- data/lib/imap/backup/cli/remote.rb +5 -1
- data/lib/imap/backup/cli/restore.rb +14 -9
- data/lib/imap/backup/cli/setup.rb +7 -2
- data/lib/imap/backup/cli/stats.rb +3 -2
- data/lib/imap/backup/cli/utils.rb +6 -3
- data/lib/imap/backup/cli.rb +11 -12
- data/lib/imap/backup/configuration.rb +4 -4
- data/lib/imap/backup/setup.rb +6 -4
- data/lib/imap/backup/version.rb +3 -3
- metadata +4 -6
- data/lib/imap/backup/cli/accounts.rb +0 -43
- data/lib/imap/backup/cli/status.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f852c0552212ba77c4e4dda834b8727860a788ea73ecf395255c248b9f728e4
|
4
|
+
data.tar.gz: 1a33b9e2efd04d4e9dcd4e48b401d7001330de8950477947aa4547d15c9554e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10ec5bf1f6426652d8b1875e1dbc4150ac7191aea988fbe2235d9966cb3394df1a6353d541f1de0c65a13c15a3b01d3502d4c36634427831244f2996a80d5bf6
|
7
|
+
data.tar.gz: eba30293362b4bc0c79e3a389cf56d3d218addec339fbc802aa245df8ef8f6f0f7b0588f6ee7ec1b5def04dbdddff39bea91370718d0dab0026cf2189474e82d
|
data/README.md
CHANGED
@@ -80,7 +80,6 @@ Alternatively, add it to your crontab.
|
|
80
80
|
* [remote folders](docs/commands/remote-folders.md)
|
81
81
|
* [restore](docs/commands/restore.md)
|
82
82
|
* [setup](docs/commands/setup.md)
|
83
|
-
* [status](docs/commands/status.md)
|
84
83
|
* [utils export-to-thunderbird](docs/commands/utils-export-to-thunderbird.md)
|
85
84
|
* [utils ignore-history](docs/commands/utils-ignore-history.md)
|
86
85
|
|
data/docs/configuration.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Configuration is stored in a JSON file.
|
2
2
|
|
3
|
-
The format is documented [here](
|
3
|
+
The format is documented [here](files/config.md).
|
4
4
|
|
5
5
|
# Folders
|
6
6
|
|
@@ -11,6 +11,8 @@ specific folders.
|
|
11
11
|
|
12
12
|
You can override the parameters passed to `Net::IMAP` with `connection_options`.
|
13
13
|
|
14
|
+
See the Ruby Standard Library documentation for `Net::IMAP` of details of [supported parameters](https://ruby-doc.org/stdlib-3.1.2/libdoc/net-imap/rdoc/Net/IMAP.html#method-c-new).
|
15
|
+
|
14
16
|
Specifically, if you are using a self-signed certificate and get SSL errors, e.g.
|
15
17
|
`certificate verify failed`, you can choose to not verify the TLS connection.
|
16
18
|
|
@@ -27,14 +27,6 @@ module Imap::Backup
|
|
27
27
|
Account::Connection::BackupFolders.new(client: client, account: account).run
|
28
28
|
end
|
29
29
|
|
30
|
-
def status
|
31
|
-
ensure_account_folder
|
32
|
-
backup_folders.map do |folder|
|
33
|
-
s = Serializer.new(account.local_path, folder.name)
|
34
|
-
{name: folder.name, local: s.uids, remote: folder.uids}
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
30
|
def run_backup(refresh: false)
|
39
31
|
Logger.logger.info "Running backup of account: #{account.username}"
|
40
32
|
# start the connection so we get logging messages in the right order
|
@@ -3,21 +3,28 @@ module Imap::Backup
|
|
3
3
|
include Thor::Actions
|
4
4
|
include CLI::Helpers
|
5
5
|
|
6
|
-
attr_reader :
|
7
|
-
attr_reader :refresh
|
6
|
+
attr_reader :options
|
8
7
|
|
9
8
|
def initialize(options)
|
10
9
|
super([])
|
11
|
-
@
|
12
|
-
@refresh = options.key?(:refresh) ? !!options[:refresh] : false
|
10
|
+
@options = options
|
13
11
|
end
|
14
12
|
|
15
13
|
no_commands do
|
16
14
|
def run
|
17
|
-
|
15
|
+
config = load_config(**options)
|
16
|
+
each_connection(config, emails) do |connection|
|
18
17
|
connection.run_backup(refresh: refresh)
|
19
18
|
end
|
20
19
|
end
|
20
|
+
|
21
|
+
def emails
|
22
|
+
(options[:accounts] || "").split(",")
|
23
|
+
end
|
24
|
+
|
25
|
+
def refresh
|
26
|
+
options.key?(:refresh) ? !!options[:refresh] : false
|
27
|
+
end
|
21
28
|
end
|
22
29
|
end
|
23
30
|
end
|
@@ -3,16 +3,18 @@ module Imap::Backup
|
|
3
3
|
include Thor::Actions
|
4
4
|
include CLI::Helpers
|
5
5
|
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :emails
|
7
|
+
attr_reader :options
|
7
8
|
|
8
9
|
def initialize(options)
|
9
10
|
super([])
|
10
|
-
@
|
11
|
+
@options = options
|
11
12
|
end
|
12
13
|
|
13
14
|
no_commands do
|
14
15
|
def run
|
15
|
-
|
16
|
+
config = load_config(**options)
|
17
|
+
each_connection(config, emails) do |connection|
|
16
18
|
Kernel.puts connection.account.username
|
17
19
|
# TODO: Make folder_names private once this command
|
18
20
|
# has been removed.
|
@@ -24,6 +26,10 @@ module Imap::Backup
|
|
24
26
|
folders.each { |f| Kernel.puts "\t#{f}" }
|
25
27
|
end
|
26
28
|
end
|
29
|
+
|
30
|
+
def emails
|
31
|
+
(options[:accounts] || "").split(",")
|
32
|
+
end
|
27
33
|
end
|
28
34
|
end
|
29
35
|
end
|
@@ -1,10 +1,18 @@
|
|
1
1
|
require "imap/backup"
|
2
|
-
require "imap/backup/cli/accounts"
|
3
2
|
|
4
3
|
module Imap::Backup
|
5
4
|
module CLI::Helpers
|
6
5
|
def self.included(base)
|
7
6
|
base.class_eval do
|
7
|
+
def self.config_option
|
8
|
+
method_option(
|
9
|
+
"config",
|
10
|
+
type: :string,
|
11
|
+
desc: "supply the configuration file path (default: ~/.imap-backup/config.json)",
|
12
|
+
aliases: ["-c"]
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
8
16
|
def self.verbose_option
|
9
17
|
method_option(
|
10
18
|
"verbose",
|
@@ -25,31 +33,49 @@ module Imap::Backup
|
|
25
33
|
end
|
26
34
|
end
|
27
35
|
|
36
|
+
def load_config(**options)
|
37
|
+
opts = symbolized(options)
|
38
|
+
path = opts[:config]
|
39
|
+
require_exists = opts.key?(:require_exists) ? opts[:require_exists] : true
|
40
|
+
if require_exists
|
41
|
+
exists = Configuration.exist?(path: path)
|
42
|
+
if !exists
|
43
|
+
expected = path || Configuration.default_pathname
|
44
|
+
raise ConfigurationNotFound, "Configuration file '#{expected}' not found"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
Configuration.new(path: path)
|
48
|
+
end
|
49
|
+
|
28
50
|
def symbolized(options)
|
29
51
|
options.each.with_object({}) do |(k, v), acc|
|
30
|
-
key =
|
52
|
+
key =
|
53
|
+
if k.is_a?(String)
|
54
|
+
k.gsub("-", "_").intern
|
55
|
+
else
|
56
|
+
k
|
57
|
+
end
|
31
58
|
acc[key] = v
|
32
59
|
end
|
33
60
|
end
|
34
61
|
|
35
|
-
def account(email)
|
36
|
-
|
37
|
-
account = accounts.find { |a| a.username == email }
|
62
|
+
def account(config, email)
|
63
|
+
account = config.accounts.find { |a| a.username == email }
|
38
64
|
raise "#{email} is not a configured account" if !account
|
39
65
|
|
40
66
|
account
|
41
67
|
end
|
42
68
|
|
43
|
-
def connection(email)
|
44
|
-
account = account(email)
|
69
|
+
def connection(config, email)
|
70
|
+
account = account(config, email)
|
45
71
|
|
46
72
|
Account::Connection.new(account)
|
47
73
|
end
|
48
74
|
|
49
|
-
def each_connection(names)
|
50
|
-
accounts
|
75
|
+
def each_connection(config, names)
|
76
|
+
config.accounts.each do |account|
|
77
|
+
next if names.any? && !names.include?(account.username)
|
51
78
|
|
52
|
-
accounts.each do |account|
|
53
79
|
yield account.connection
|
54
80
|
end
|
55
81
|
rescue ConfigurationNotFound
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require "imap/backup/cli/accounts"
|
2
|
-
|
3
1
|
module Imap::Backup
|
4
2
|
class CLI::Local < Thor
|
5
3
|
include Thor::Actions
|
@@ -8,14 +6,17 @@ module Imap::Backup
|
|
8
6
|
MAX_SUBJECT = 60
|
9
7
|
|
10
8
|
desc "accounts", "List locally backed-up accounts"
|
9
|
+
config_option
|
11
10
|
def accounts
|
12
|
-
|
13
|
-
accounts.each { |a| Kernel.puts a.username }
|
11
|
+
config = load_config(**symbolized(options))
|
12
|
+
config.accounts.each { |a| Kernel.puts a.username }
|
14
13
|
end
|
15
14
|
|
16
15
|
desc "folders EMAIL", "List backed up folders"
|
16
|
+
config_option
|
17
17
|
def folders(email)
|
18
|
-
|
18
|
+
config = load_config(**symbolized(options))
|
19
|
+
connection = connection(config, email)
|
19
20
|
|
20
21
|
connection.local_folders.each do |_s, f|
|
21
22
|
Kernel.puts %("#{f.name}")
|
@@ -23,8 +24,10 @@ module Imap::Backup
|
|
23
24
|
end
|
24
25
|
|
25
26
|
desc "list EMAIL FOLDER", "List emails in a folder"
|
27
|
+
config_option
|
26
28
|
def list(email, folder_name)
|
27
|
-
|
29
|
+
config = load_config(**symbolized(options))
|
30
|
+
connection = connection(config, email)
|
28
31
|
|
29
32
|
folder_serializer, _folder = connection.local_folders.find do |(_s, f)|
|
30
33
|
f.name == folder_name
|
@@ -50,8 +53,10 @@ module Imap::Backup
|
|
50
53
|
If more than one UID is given, they are separated by a header indicating
|
51
54
|
the UID.
|
52
55
|
DESC
|
56
|
+
config_option
|
53
57
|
def show(email, folder_name, uids)
|
54
|
-
|
58
|
+
config = load_config(**symbolized(options))
|
59
|
+
connection = connection(config, email)
|
55
60
|
|
56
61
|
folder_serializer, _folder = connection.local_folders.find do |(_s, f)|
|
57
62
|
f.name == folder_name
|
@@ -3,9 +3,11 @@ require "imap/backup/migrator"
|
|
3
3
|
module Imap::Backup
|
4
4
|
class CLI::Migrate < Thor
|
5
5
|
include Thor::Actions
|
6
|
+
include CLI::Helpers
|
6
7
|
|
7
8
|
attr_reader :destination_email
|
8
9
|
attr_reader :destination_prefix
|
10
|
+
attr_reader :config_path
|
9
11
|
attr_reader :reset
|
10
12
|
attr_reader :source_email
|
11
13
|
attr_reader :source_prefix
|
@@ -13,6 +15,7 @@ module Imap::Backup
|
|
13
15
|
def initialize(
|
14
16
|
source_email,
|
15
17
|
destination_email,
|
18
|
+
config: nil,
|
16
19
|
destination_prefix: "",
|
17
20
|
reset: false,
|
18
21
|
source_prefix: ""
|
@@ -20,6 +23,7 @@ module Imap::Backup
|
|
20
23
|
super([])
|
21
24
|
@destination_email = destination_email
|
22
25
|
@destination_prefix = destination_prefix
|
26
|
+
@config_path = config
|
23
27
|
@reset = reset
|
24
28
|
@source_email = source_email
|
25
29
|
@source_prefix = source_prefix
|
@@ -44,7 +48,7 @@ module Imap::Backup
|
|
44
48
|
end
|
45
49
|
|
46
50
|
def config
|
47
|
-
|
51
|
+
@config ||= load_config(config: config_path)
|
48
52
|
end
|
49
53
|
|
50
54
|
def destination_account
|
@@ -3,21 +3,25 @@ require "imap/backup/mirror"
|
|
3
3
|
module Imap::Backup
|
4
4
|
class CLI::Mirror < Thor
|
5
5
|
include Thor::Actions
|
6
|
+
include CLI::Helpers
|
6
7
|
|
7
8
|
attr_reader :destination_email
|
8
9
|
attr_reader :destination_prefix
|
10
|
+
attr_reader :config_path
|
9
11
|
attr_reader :source_email
|
10
12
|
attr_reader :source_prefix
|
11
13
|
|
12
14
|
def initialize(
|
13
15
|
source_email,
|
14
16
|
destination_email,
|
17
|
+
config: nil,
|
15
18
|
destination_prefix: "",
|
16
19
|
source_prefix: ""
|
17
20
|
)
|
18
21
|
super([])
|
19
22
|
@destination_email = destination_email
|
20
23
|
@destination_prefix = destination_prefix
|
24
|
+
@config_path = config
|
21
25
|
@source_email = source_email
|
22
26
|
@source_prefix = source_prefix
|
23
27
|
end
|
@@ -27,7 +31,7 @@ module Imap::Backup
|
|
27
31
|
check_accounts!
|
28
32
|
warn_if_source_account_is_not_in_mirror_mode
|
29
33
|
|
30
|
-
CLI::Backup.new(accounts: source_email).run
|
34
|
+
CLI::Backup.new(config: config_path, accounts: source_email).run
|
31
35
|
|
32
36
|
folders.each do |serializer, folder|
|
33
37
|
Mirror.new(serializer, folder).run
|
@@ -54,7 +58,7 @@ module Imap::Backup
|
|
54
58
|
end
|
55
59
|
|
56
60
|
def config
|
57
|
-
|
61
|
+
@config = load_config(config: config_path)
|
58
62
|
end
|
59
63
|
|
60
64
|
def destination_account
|
@@ -4,8 +4,12 @@ module Imap::Backup
|
|
4
4
|
include CLI::Helpers
|
5
5
|
|
6
6
|
desc "folders EMAIL", "List account folders"
|
7
|
+
config_option
|
8
|
+
verbose_option
|
9
|
+
quiet_option
|
7
10
|
def folders(email)
|
8
|
-
|
11
|
+
config = load_config(**symbolized(options))
|
12
|
+
connection = connection(config, email)
|
9
13
|
|
10
14
|
connection.folder_names.each do |name|
|
11
15
|
Kernel.puts %("#{name}")
|
@@ -4,33 +4,38 @@ module Imap::Backup
|
|
4
4
|
include CLI::Helpers
|
5
5
|
|
6
6
|
attr_reader :email
|
7
|
-
attr_reader :
|
7
|
+
attr_reader :options
|
8
8
|
|
9
9
|
def initialize(email = nil, options)
|
10
10
|
super([])
|
11
11
|
@email = email
|
12
|
-
@
|
12
|
+
@options = options
|
13
13
|
end
|
14
14
|
|
15
15
|
no_commands do
|
16
16
|
def run
|
17
|
+
config = load_config(**options)
|
17
18
|
case
|
18
|
-
when email && !
|
19
|
-
connection = connection(email)
|
19
|
+
when email && !emails
|
20
|
+
connection = connection(config, email)
|
20
21
|
connection.restore
|
21
|
-
when !email && !
|
22
|
+
when !email && !emails
|
22
23
|
Logger.logger.info "Calling restore without an EMAIL parameter is deprecated"
|
23
|
-
each_connection([], &:restore)
|
24
|
-
when email &&
|
24
|
+
each_connection(config, [], &:restore)
|
25
|
+
when email && emails.any?
|
25
26
|
raise "Pass either an email or the --accounts option, not both"
|
26
|
-
when
|
27
|
+
when emails.any?
|
27
28
|
Logger.logger.info(
|
28
29
|
"Calling restore with the --account option is deprected, " \
|
29
30
|
"please pass a single EMAIL argument"
|
30
31
|
)
|
31
|
-
each_connection(
|
32
|
+
each_connection(config, emails, &:restore)
|
32
33
|
end
|
33
34
|
end
|
35
|
+
|
36
|
+
def emails
|
37
|
+
@emails ||= options[:accounts].split(",") if options.key?(:accounts)
|
38
|
+
end
|
34
39
|
end
|
35
40
|
end
|
36
41
|
end
|
@@ -1,14 +1,19 @@
|
|
1
1
|
module Imap::Backup
|
2
2
|
class CLI::Setup < Thor
|
3
3
|
include Thor::Actions
|
4
|
+
include CLI::Helpers
|
4
5
|
|
5
|
-
|
6
|
+
attr_reader :options
|
7
|
+
|
8
|
+
def initialize(options)
|
6
9
|
super([])
|
10
|
+
@options = options
|
7
11
|
end
|
8
12
|
|
9
13
|
no_commands do
|
10
14
|
def run
|
11
|
-
|
15
|
+
config = load_config(**options, require_exists: false)
|
16
|
+
Setup.new(config: config).run
|
12
17
|
end
|
13
18
|
end
|
14
19
|
end
|
@@ -14,7 +14,7 @@ module Imap::Backup
|
|
14
14
|
attr_reader :email
|
15
15
|
attr_reader :options
|
16
16
|
|
17
|
-
def initialize(email, options
|
17
|
+
def initialize(email, options)
|
18
18
|
super([])
|
19
19
|
@email = email
|
20
20
|
@options = options
|
@@ -31,7 +31,8 @@ module Imap::Backup
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def stats
|
34
|
-
|
34
|
+
config = load_config(**options)
|
35
|
+
connection = connection(config, email)
|
35
36
|
|
36
37
|
connection.backup_folders.map do |folder|
|
37
38
|
next if !folder.exist?
|
@@ -11,8 +11,10 @@ module Imap::Backup
|
|
11
11
|
verbose_option
|
12
12
|
quiet_option
|
13
13
|
def ignore_history(email)
|
14
|
-
|
15
|
-
|
14
|
+
opts = symbolized(options)
|
15
|
+
Imap::Backup::Logger.setup_logging opts
|
16
|
+
config = load_config(**opts)
|
17
|
+
connection = connection(config, email)
|
16
18
|
|
17
19
|
connection.backup_folders.each do |folder|
|
18
20
|
next if !folder.exist?
|
@@ -49,7 +51,8 @@ module Imap::Backup
|
|
49
51
|
force = opts.key?(:force) ? opts[:force] : false
|
50
52
|
profile_name = opts[:profile]
|
51
53
|
|
52
|
-
|
54
|
+
config = load_config(**opts)
|
55
|
+
connection = connection(config, email)
|
53
56
|
profile = thunderbird_profile(profile_name)
|
54
57
|
|
55
58
|
if !profile
|
data/lib/imap/backup/cli.rb
CHANGED
@@ -16,7 +16,6 @@ module Imap::Backup
|
|
16
16
|
autoload :Restore, "imap/backup/cli/restore"
|
17
17
|
autoload :Setup, "imap/backup/cli/setup"
|
18
18
|
autoload :Stats, "imap/backup/cli/stats"
|
19
|
-
autoload :Status, "imap/backup/cli/status"
|
20
19
|
autoload :Utils, "imap/backup/cli/utils"
|
21
20
|
|
22
21
|
include Helpers
|
@@ -45,6 +44,7 @@ module Imap::Backup
|
|
45
44
|
The setup tool can be used to choose a specific list of folders to back up.
|
46
45
|
DESC
|
47
46
|
accounts_option
|
47
|
+
config_option
|
48
48
|
verbose_option
|
49
49
|
quiet_option
|
50
50
|
method_option(
|
@@ -66,6 +66,7 @@ module Imap::Backup
|
|
66
66
|
and `imap-backup remote folders ACCOUNT` to get the folder list.
|
67
67
|
DESC
|
68
68
|
accounts_option
|
69
|
+
config_option
|
69
70
|
def folders
|
70
71
|
Folders.new(symbolized(options)).run
|
71
72
|
end
|
@@ -96,6 +97,7 @@ module Imap::Backup
|
|
96
97
|
use the `--reset` option. In this case, all existing emails are
|
97
98
|
deleted before uploading the migrated emails.
|
98
99
|
DESC
|
100
|
+
config_option
|
99
101
|
verbose_option
|
100
102
|
quiet_option
|
101
103
|
method_option(
|
@@ -141,6 +143,7 @@ module Imap::Backup
|
|
141
143
|
This file has a '.mirror' extension. This file contains a mapping of
|
142
144
|
the known UIDs on the source account to those on the destination account.
|
143
145
|
DESC
|
146
|
+
config_option
|
144
147
|
verbose_option
|
145
148
|
quiet_option
|
146
149
|
method_option(
|
@@ -169,6 +172,7 @@ module Imap::Backup
|
|
169
172
|
their original server.
|
170
173
|
DESC
|
171
174
|
accounts_option
|
175
|
+
config_option
|
172
176
|
verbose_option
|
173
177
|
quiet_option
|
174
178
|
def restore(email = nil)
|
@@ -181,11 +185,12 @@ module Imap::Backup
|
|
181
185
|
A menu-driven command-line application used to configure imap-backup.
|
182
186
|
Configure email accounts to back up.
|
183
187
|
DESC
|
188
|
+
config_option
|
184
189
|
verbose_option
|
185
190
|
quiet_option
|
186
191
|
def setup
|
187
192
|
Imap::Backup::Logger.setup_logging symbolized(options)
|
188
|
-
Setup.new.run
|
193
|
+
Setup.new(symbolized(options)).run
|
189
194
|
end
|
190
195
|
|
191
196
|
desc "stats EMAIL [OPTIONS]", "Print stats for each account folder"
|
@@ -194,6 +199,9 @@ module Imap::Backup
|
|
194
199
|
are downloaded (exist on server and locally) "both" and those which
|
195
200
|
are only present in the backup (as they have been deleted on the server) "local".
|
196
201
|
DESC
|
202
|
+
config_option
|
203
|
+
verbose_option
|
204
|
+
quiet_option
|
197
205
|
method_option(
|
198
206
|
"format",
|
199
207
|
type: :string,
|
@@ -201,19 +209,10 @@ module Imap::Backup
|
|
201
209
|
aliases: ["-f"]
|
202
210
|
)
|
203
211
|
def stats(email)
|
212
|
+
Imap::Backup::Logger.setup_logging symbolized(options)
|
204
213
|
Stats.new(email, symbolized(options)).run
|
205
214
|
end
|
206
215
|
|
207
|
-
desc "status", "This command is deprecated, use `imap-backup stats ACCOUNT`"
|
208
|
-
long_desc <<~DESC
|
209
|
-
For each configured account and folder, lists the number of emails yet to be downloaded.
|
210
|
-
This command is deprecated.
|
211
|
-
DESC
|
212
|
-
accounts_option
|
213
|
-
def status
|
214
|
-
Status.new(symbolized(options)).run
|
215
|
-
end
|
216
|
-
|
217
216
|
desc "utils SUBCOMMAND [OPTIONS]", "Various utilities"
|
218
217
|
subcommand "utils", Utils
|
219
218
|
end
|
@@ -14,12 +14,12 @@ module Imap::Backup
|
|
14
14
|
File.join(CONFIGURATION_DIRECTORY, "config.json")
|
15
15
|
end
|
16
16
|
|
17
|
-
def self.exist?(
|
18
|
-
File.exist?(
|
17
|
+
def self.exist?(path: nil)
|
18
|
+
File.exist?(path || default_pathname)
|
19
19
|
end
|
20
20
|
|
21
|
-
def initialize(
|
22
|
-
@pathname =
|
21
|
+
def initialize(path: nil)
|
22
|
+
@pathname = path || self.class.default_pathname
|
23
23
|
end
|
24
24
|
|
25
25
|
def path
|
data/lib/imap/backup/setup.rb
CHANGED
@@ -11,6 +11,12 @@ module Imap::Backup
|
|
11
11
|
end
|
12
12
|
self.highline = HighLine.new
|
13
13
|
|
14
|
+
attr_accessor :config
|
15
|
+
|
16
|
+
def initialize(config:)
|
17
|
+
@config = config
|
18
|
+
end
|
19
|
+
|
14
20
|
def run
|
15
21
|
catch :done do
|
16
22
|
loop do
|
@@ -62,10 +68,6 @@ module Imap::Backup
|
|
62
68
|
end
|
63
69
|
end
|
64
70
|
|
65
|
-
def config
|
66
|
-
@config ||= Configuration.new
|
67
|
-
end
|
68
|
-
|
69
71
|
def default_account_config(username)
|
70
72
|
Imap::Backup::Account.new(
|
71
73
|
username: username,
|
data/lib/imap/backup/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imap-backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 8.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Yates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -239,7 +239,6 @@ files:
|
|
239
239
|
- lib/imap/backup/account/connection/folder_names.rb
|
240
240
|
- lib/imap/backup/account/folder.rb
|
241
241
|
- lib/imap/backup/cli.rb
|
242
|
-
- lib/imap/backup/cli/accounts.rb
|
243
242
|
- lib/imap/backup/cli/backup.rb
|
244
243
|
- lib/imap/backup/cli/folders.rb
|
245
244
|
- lib/imap/backup/cli/helpers.rb
|
@@ -250,7 +249,6 @@ files:
|
|
250
249
|
- lib/imap/backup/cli/restore.rb
|
251
250
|
- lib/imap/backup/cli/setup.rb
|
252
251
|
- lib/imap/backup/cli/stats.rb
|
253
|
-
- lib/imap/backup/cli/status.rb
|
254
252
|
- lib/imap/backup/cli/utils.rb
|
255
253
|
- lib/imap/backup/client/apple_mail.rb
|
256
254
|
- lib/imap/backup/client/default.rb
|
@@ -302,9 +300,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
302
300
|
version: '2.6'
|
303
301
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
304
302
|
requirements:
|
305
|
-
- - "
|
303
|
+
- - ">"
|
306
304
|
- !ruby/object:Gem::Version
|
307
|
-
version:
|
305
|
+
version: 1.3.1
|
308
306
|
requirements: []
|
309
307
|
rubygems_version: 3.3.7
|
310
308
|
signing_key:
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Imap::Backup
|
2
|
-
class CLI; end
|
3
|
-
|
4
|
-
class CLI::Accounts
|
5
|
-
include Enumerable
|
6
|
-
|
7
|
-
attr_reader :required_accounts
|
8
|
-
|
9
|
-
def initialize(required_accounts = [])
|
10
|
-
@required_accounts = required_accounts
|
11
|
-
end
|
12
|
-
|
13
|
-
def each(&block)
|
14
|
-
return enum_for(:each) if !block
|
15
|
-
|
16
|
-
accounts.each(&block)
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def accounts
|
22
|
-
@accounts ||=
|
23
|
-
if required_accounts.empty?
|
24
|
-
config.accounts
|
25
|
-
else
|
26
|
-
config.accounts.select do |account|
|
27
|
-
required_accounts.include?(account.username)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def config
|
33
|
-
@config ||= begin
|
34
|
-
exists = Configuration.exist?
|
35
|
-
if !exists
|
36
|
-
path = Configuration.default_pathname
|
37
|
-
raise ConfigurationNotFound, "Configuration file '#{path}' not found"
|
38
|
-
end
|
39
|
-
Configuration.new
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Imap::Backup
|
2
|
-
class CLI::Status < Thor
|
3
|
-
include Thor::Actions
|
4
|
-
include CLI::Helpers
|
5
|
-
|
6
|
-
attr_reader :account_names
|
7
|
-
|
8
|
-
def initialize(options)
|
9
|
-
super([])
|
10
|
-
@account_names = (options[:accounts] || "").split(",")
|
11
|
-
end
|
12
|
-
|
13
|
-
no_commands do
|
14
|
-
def run
|
15
|
-
each_connection(account_names) do |connection|
|
16
|
-
Kernel.puts connection.account.username
|
17
|
-
folders = connection.status
|
18
|
-
folders.each do |f|
|
19
|
-
missing_locally = f[:remote] - f[:local]
|
20
|
-
Kernel.puts "#{f[:name]}: #{missing_locally.size}"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|