+ parsed_uri = URI(uri)
+
+ source =
+ case parsed_uri.scheme
+ when "mbox+ssh"
+ say "For SSH connections, if you will use public key authentication, you may leave the username and password blank."
+ say ""
+ username, password = get_login_info uri, Redwood::SourceManager.sources
+ Redwood::MBox::SSHLoader.new uri, username, password, nil, !$opts[:unusual], $opts[:archive], nil, labels
+ when "imap", "imaps"
+ username, password = get_login_info uri, Redwood::SourceManager.sources
+ Redwood::IMAP.new uri, username, password, nil, !$opts[:unusual], $opts[:archive], nil, labels
+ when "maildir"
+ Redwood::Maildir.new uri, nil, !$opts[:unusual], $opts[:archive], nil, labels
+ when "mbox"
+ Redwood::MBox::Loader.new uri, nil, !$opts[:unusual], $opts[:archive], nil, labels
+ when nil
+ Trollop::die "Sources must be specified with an URI"
+ else
+ Trollop::die "Unknown source type #{parsed_uri.scheme.inspect}"
+ end
+ say "Adding #{source}..."
+ Redwood::SourceManager.add_source source
+ end
+ensure
+ index.save
+ index.unlock
+ Redwood::finish
+end