- say "Now for the details."
-
- components =
- case type
- when :mbox
- fn = axe "What's the full path to the mbox file?", ENV["MAIL"] #"srm
- return if fn.nil? || fn.empty?
- { :scheme => "mbox", :path => fn }
- when :maildir
- fn = axe "What's the full path to the maildir directory?", ENV["MAIL"] #"srm
- return if fn.nil? || fn.empty?
- { :scheme => "maildir", :path => fn }
- when :mboxssh
- srv = axe "What server is the mbox file located on?", $last_server
- return if srv.nil? || srv.empty?
- $last_server = srv
- fn = axe "What's the full path to the mbox file?", ENV["MAIL"] #"srm
- return if fn.nil? || fn.empty?
- { :scheme => "mbox+ssh", :host => srv, :path => fn }
- when :imap, :imaps
- srv = axe "What is the IMAP server?", $last_server
- return if srv.nil? || srv.empty?
- $last_server = srv
- fn = axe "What's the folder path?", "INBOX" #"srm
- return if fn.nil? || fn.empty?
- fn = "/#{fn}" # lame
- { :scheme => type.to_s, :host => srv, :path => fn }
- end
-
- uri =
- begin
- URI::Generic.build components
- rescue URI::Error => e
- say "Whoopsie! I couldn't build a URI from that: #{e.message}"
- if axe_yes("Try again?") then next else return end
+ say "Ok, now for the details."
+
+ default_labels, components = case type
+ when :mbox
+ $last_fn ||= ENV["MAIL"]
+ fn = axe "What's the full path to the mbox file?", $last_fn
+ return if fn.nil? || fn.empty?
+
+ $last_fn = fn
+ [Redwood::MBox::Loader.suggest_labels_for(fn),
+ { :scheme => "mbox", :path => fn }]
+ when :maildir
+ $last_fn ||= ENV["MAIL"]
+ fn = axe "What's the full path to the maildir directory?", $last_fn
+ return if fn.nil? || fn.empty?
+
+ $last_fn = fn
+ [Redwood::Maildir.suggest_labels_for(fn),
+ { :scheme => "maildir", :path => fn }]
+ when :mboxssh
+ $last_server ||= "localhost"
+ srv = axe "What machine is the mbox file located on?", $last_server
+ return if srv.nil? || srv.empty?
+ $last_server = srv
+
+ fn = axe "What's the path to the mbox file?", $last_fn
+ return if fn.nil? || fn.empty?
+ $last_fn = fn
+ fn = "/#{fn}" # lame
+ [Redwood::MBox::SSHLoader.suggest_labels_for(fn),
+ { :scheme => "mbox+ssh", :host => srv, :path => fn }]
+ when :imap, :imaps
+ $last_server ||= "localhost"
+ srv = axe "What is the IMAP server (host, or host:port notation)?", $last_server
+ return if srv.nil? || srv.empty?
+ $last_server = srv
+
+ $last_folder ||= "INBOX"
+ fn = axe "What's the folder path?", $last_folder
+ return if fn.nil? || fn.empty?
+ $last_folder = fn
+
+ fn = "/#{fn}"
+ if srv =~ /^(\S+):(\d+)$/
+ host, port = $1, $2.to_i
+ else
+ host, port = srv, nil