From: Tero Tilus <tero@tilus.net>
To: sup-talk@rubyforge.org
Subject: [sup-talk] IMAP and recursion
Date: Tue, 13 Oct 2009 15:40:03 +0300 [thread overview]
Message-ID: <20091013124002.GA7129@tilus.net> (raw)
I had quite a lot of IMAP folders to add and went looking for
recursion. I found old sup-talk threads on the subject and thought of
it a while.
I might have missed something, but I could not easily get around
sup-add asking me all the time which account she should use. So I
went on to add --force-account user@host to be able to batch-add IMAP
sources.
What do you think?
---
diff --git a/bin/sup-add b/bin/sup-add
index e27a0eb..c53378d 100755
--- a/bin/sup-add
+++ b/bin/sup-add
@@ -39,6 +39,7 @@ EOS
opt :unusual, "Do not automatically poll these sources for new messages."
opt :labels, "A comma-separated set of labels to apply to all messages from this source", :type => String
opt :force_new, "Create a new account for this source, even if one already exists."
+ opt :force_account, "Reuse previously defined account user@hostname.", :type => String
end
Trollop::die "require one or more sources" if ARGV.empty?
@@ -56,13 +57,20 @@ def get_login_info uri, sources
username, password = nil, nil
unless accounts.empty? || $opts[:force_new]
- say "Would you like to use the same account as for a previous source for #{uri}?"
- choose do |menu|
- accounts.each do |host, olduser, oldpw|
- menu.choice("Use the account info for #{olduser}@#{host}") { username, password = olduser, oldpw }
+ if $opts[:force_account]
+ host, username, password = accounts.find { |h, u, p| $opts[:force_account] == "#{u}@#{h}" }
+ unless username && password
+ say "No previous account #{$opts[:force_account].inspect} found."
+ end
+ else
+ say "Would you like to use the same account as for a previous source for #{uri}?"
+ choose do |menu|
+ accounts.each do |host, olduser, oldpw|
+ menu.choice("Use the account info for #{olduser}@#{host}") { username, password = olduser, oldpw }
+ end
+ menu.choice("Use a new account") { }
+ menu.prompt = "Account selection? "
end
- menu.choice("Use a new account") { }
- menu.prompt = "Account selection? "
end
end
---
--
Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk
reply other threads:[~2009-10-13 12:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091013124002.GA7129@tilus.net \
--to=tero@tilus.net \
--cc=sup-talk@rubyforge.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox