bin/sup-add in sup-0.9.1 vs bin/sup-add in sup-0.10

- old
+ new

@@ -2,11 +2,11 @@ require 'uri' require 'rubygems' require 'highline/import' require 'trollop' -require "sup" +require "sup"; Redwood::check_library_version_against "0.10" $opts = Trollop::options do version "sup-add (sup #{Redwood::VERSION})" banner <<EOS Adds a source to the Sup source list. @@ -37,10 +37,12 @@ EOS opt :archive, "Automatically archive all new messages from these sources." 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 + opt :index, "Use this index type ('auto' for autodetect)", :default => "auto" end Trollop::die "require one or more sources" if ARGV.empty? ## for sources that require login information, prompt the user for @@ -54,17 +56,24 @@ [suri.host, s.username, s.password] end.compact.uniq.sort_by { |h, u, p| h == uri.host ? 0 : 1 } 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 - menu.choice("Use a new account") { } - menu.prompt = "Account selection? " + 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 end end unless username && password username = ask("Username for #{uri.host}: "); @@ -75,10 +84,11 @@ [username, password] end $terminal.wrap_at = :auto Redwood::start -index = Redwood::Index.init +index = Redwood::Index.init $opts[:index] +index.load index.lock_interactively or exit begin Redwood::SourceManager.load_sources