diff options
author | Simon Parri <simonparri@ganzeria.com> | 2020-10-22 13:45:54 -0500 |
---|---|---|
committer | Simon Parri <simonparri@ganzeria.com> | 2020-10-22 13:45:54 -0500 |
commit | 7ae110e6454715f479335f44c1384c25a5025e92 (patch) | |
tree | 9fbdc9869f1ae2991bdcf844974f32db0f515ac7 | |
parent | 55caa437159a70760d4a03f5a45c9802805e202a (diff) | |
download | spelling-rbee-7ae110e6454715f479335f44c1384c25a5025e92.tar.gz spelling-rbee-7ae110e6454715f479335f44c1384c25a5025e92.zip |
Add option to make spelling-rbead output to file
-rwxr-xr-x | spelling-rbead | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/spelling-rbead b/spelling-rbead index 980a7bb..4d92118 100755 --- a/spelling-rbead +++ b/spelling-rbead @@ -1,12 +1,14 @@ #!/usr/bin/ruby %w[net/imap readline optparse].each do |m| require m end +$file = nil OptionParser.new do |opts| opts.banner = "Usage: spelling-rbead [options]" opts.on("-uUSER", "--user=USER", "User to log in as") 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("-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! @@ -26,5 +28,11 @@ if !$help end imap.logout - puts words + if $file + open $file, "w" do |f| + f.puts words + end + else + puts words + end end |