vmail 2.0.5 → 2.0.6
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.
- data/bin/vmail +4 -6
- data/lib/vmail.rb +0 -52
- data/lib/vmail/version.rb +1 -1
- metadata +1 -1
data/bin/vmail
CHANGED
@@ -7,11 +7,9 @@ rescue LoadError
|
|
7
7
|
require 'vmail'
|
8
8
|
end
|
9
9
|
|
10
|
-
if !STDOUT.tty?
|
11
|
-
Vmail
|
12
|
-
elsif !STDIN.tty?
|
13
|
-
Vmail.batch_run
|
14
|
-
else
|
15
|
-
Vmail.start
|
10
|
+
if !STDOUT.tty? || !STDIN.tty?
|
11
|
+
abort "Vmail non-interactive mode has been removed"
|
16
12
|
end
|
17
13
|
|
14
|
+
Vmail.start
|
15
|
+
|
data/lib/vmail.rb
CHANGED
@@ -92,58 +92,6 @@ module Vmail
|
|
92
92
|
exit
|
93
93
|
end
|
94
94
|
|
95
|
-
# non-interactive mode
|
96
|
-
def noninteractive_list_messages
|
97
|
-
check_lynx
|
98
|
-
opts = Vmail::Options.new(ARGV)
|
99
|
-
opts.config
|
100
|
-
config = opts.config.merge 'logfile' => 'vmail.log'
|
101
|
-
mailbox, query = parse_query
|
102
|
-
query_string = Vmail::Query.args2string query
|
103
|
-
imap_client = Vmail::ImapClient.new config
|
104
|
-
imap_client.with_open do |vmail|
|
105
|
-
vmail.select_mailbox mailbox
|
106
|
-
vmail.search query_string
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
# batch processing mode
|
111
|
-
def batch_run
|
112
|
-
check_lynx
|
113
|
-
opts = Vmail::Options.new(ARGV)
|
114
|
-
opts.config
|
115
|
-
config = opts.config.merge 'logfile' => 'vmail.log'
|
116
|
-
# no search query args, but command args
|
117
|
-
imap_client = Vmail::ImapClient.new config
|
118
|
-
lines = STDIN.readlines# .reverse
|
119
|
-
mailbox = lines.shift.chomp
|
120
|
-
puts "mailbox: #{mailbox}"
|
121
|
-
uid_set = lines.map do |line|
|
122
|
-
line[/(\d+)\s*$/,1].to_i
|
123
|
-
end
|
124
|
-
commands = {
|
125
|
-
'rm' => ["flag", "+FLAGS", "Deleted"],
|
126
|
-
'spam' => ["flag", "+FLAGS", "spam"],
|
127
|
-
'mv' => ["move_to"],
|
128
|
-
'cp' => ["copy_to"],
|
129
|
-
'print' => ["append_to_file"]
|
130
|
-
}
|
131
|
-
args = commands[ARGV.first]
|
132
|
-
if args.nil?
|
133
|
-
abort "Command '#{args.inspect}' not recognized"
|
134
|
-
end
|
135
|
-
command = args.shift
|
136
|
-
imap_client.with_open do |vmail|
|
137
|
-
puts "Selecting mailbox: #{mailbox}"
|
138
|
-
vmail.select_mailbox mailbox
|
139
|
-
uid_set.each_slice(5) do |uid_set|
|
140
|
-
params = [uid_set.join(',')] + args + ARGV[1..-1]
|
141
|
-
puts "Executing: #{command} #{params.join(' ')}"
|
142
|
-
vmail.send command, *params
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
95
|
private
|
148
96
|
|
149
97
|
def check_lynx
|
data/lib/vmail/version.rb
CHANGED