* [sup-devel] [PATCH] reuse old account info with --foce-account user@hostname option
@ 2009-12-30 4:06 Tero Tilus
2009-12-31 19:16 ` William Morgan
0 siblings, 1 reply; 2+ messages in thread
From: Tero Tilus @ 2009-12-30 4:06 UTC (permalink / raw)
To: Sup developers
Signed-off-by: Tero Tilus <tero@tilus.net>
---
bin/sup-add | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
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-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-12-31 19:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-30 4:06 [sup-devel] [PATCH] reuse old account info with --foce-account user@hostname option Tero Tilus
2009-12-31 19:16 ` William Morgan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox