summaryrefslogtreecommitdiff
path: root/spelling-rbead
diff options
context:
space:
mode:
authorSimon Parri <simonparri@ganzeria.com>2023-04-29 17:04:45 -0500
committerSimon Parri <simonparri@ganzeria.com>2023-04-29 19:39:08 -0500
commit67874102d9e6cea209dea6421881393b3eb0f845 (patch)
tree4e6b2ddeb5a678893fb2738afb152b90f49216ce /spelling-rbead
parent15994bcd811e8f331fb302eda9f15b56b5e11fcf (diff)
downloadspelling-rbee-67874102d9e6cea209dea6421881393b3eb0f845.tar.gz
spelling-rbee-67874102d9e6cea209dea6421881393b3eb0f845.zip
spelling-rbead: Neaten up code
+ Use [].each &Kernel.method :require + Initialize $subject rather than doing $subject || + Change `if !' to `unless' + Remove superfluous parentheses
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