From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.90.117.16 with SMTP id p16cs413096agc; Tue, 13 Oct 2009 05:40:33 -0700 (PDT) Received: by 10.224.43.102 with SMTP id v38mr5766574qae.104.1255437632465; Tue, 13 Oct 2009 05:40:32 -0700 (PDT) Return-Path: Received: from rubyforge.org (rubyforge.org [205.234.109.19]) by mx.google.com with ESMTP id 16si5925712qyk.15.2009.10.13.05.40.32; Tue, 13 Oct 2009 05:40:32 -0700 (PDT) Received-SPF: pass (google.com: domain of sup-talk-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) client-ip=205.234.109.19; Authentication-Results: mx.google.com; spf=pass (google.com: domain of sup-talk-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) smtp.mail=sup-talk-bounces@rubyforge.org Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 0FD49121825B; Tue, 13 Oct 2009 08:40:32 -0400 (EDT) Received: from kuovi.tilus.net (kuovi.tilus.net [80.68.89.168]) by rubyforge.org (Postfix) with ESMTP id 7296E1978285 for ; Tue, 13 Oct 2009 08:40:04 -0400 (EDT) Received: by kuovi.tilus.net (Postfix, from userid 1000) id D751F6011; Tue, 13 Oct 2009 13:40:03 +0100 (BST) Date: Tue, 13 Oct 2009 15:40:03 +0300 From: Tero Tilus To: sup-talk@rubyforge.org Message-ID: <20091013124002.GA7129@tilus.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Subject: [sup-talk] IMAP and recursion X-BeenThere: sup-talk@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: tero@tilus.net List-Id: User & developer discussion of Sup List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: sup-talk-bounces@rubyforge.org Errors-To: sup-talk-bounces@rubyforge.org 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