summaryrefslogtreecommitdiff
path: root/spelling-rbead
diff options
context:
space:
mode:
Diffstat (limited to 'spelling-rbead')
-rwxr-xr-xspelling-rbead14
1 files changed, 8 insertions, 6 deletions
diff --git a/spelling-rbead b/spelling-rbead
index 9df7414..8245c30 100755
--- a/spelling-rbead
+++ b/spelling-rbead
@@ -1,26 +1,28 @@
#!/usr/bin/ruby
-%w[net/imap readline optparse].each do |m| require m end
+%w[net/imap readline optparse]
+ .each &Kernel.method(:require)
$file = nil
+$subject = "Spelling:"
+
OptionParser.new do |opts|
opts.banner = "Usage: spelling-rbead [options]"
opts.on("-uUSER", "--user=USER", "Log in as USER") do |u| $user = u; end
opts.on("-fADDR", "--from=ADDR", "Search from ADDR") do |a| $from = a; end
opts.on("-sSUBJ", "--subject=SUBJ", "Search for SUBJ") do |s| $subject = s; end
- opts.on("-mSERVER", "--mailserver=SERVER", "Connect to SERVER") do |m| $mailbox = m; end
+ opts.on("-mSERVER", "--mailserver=SERVER", "Connect to SERVER") do |m| $server = m; end
opts.on("-o", "--output=FILE", "Output to FILE") do |f| $file = f; end
opts.on("-h", "--help", "Get help") do puts opts; $help = true; end
end.parse!
-if !$help
+unless $help
$stderr.print "Password: "
$password = Readline.readline
$stderr.puts
- $subject ||= "Spelling:"
#Net::IMAP.debug = true
- imap = Net::IMAP.new($mailbox)
- imap.login($user, $password)
+ imap = Net::IMAP.new $server
+ imap.login $user, $password
imap.select "inbox"
n = imap.search("FROM \"#{$from}\" SUBJECT \"#{$subject}\"").last
if n