]> git.cworth.org Git - sup/commitdiff
sup-config: add awareness of non-default sent source
authorBen Walton <bwalton@artsci.utoronto.ca>
Thu, 7 May 2009 21:23:50 +0000 (17:23 -0400)
committerBen Walton <bwalton@artsci.utoronto.ca>
Thu, 28 May 2009 15:27:23 +0000 (11:27 -0400)
The user is now prompted to select a source to store sent mail in.
Only sources that are capable of storing mail are presented.  The
default sup://sent is available as an option too.

bin/sup-config

index f978a6b5d6dc9831913d83e1eaeb9f6e49d059e2..398197f512205207a2045c374752372ce486d9a5 100755 (executable)
@@ -187,9 +187,6 @@ $config[:accounts][:default][:alternates] = alts
 $config[:accounts][:default][:signature] = sigfn
 $config[:editor] = editor
 
-Redwood::save_yaml_obj $config, Redwood::CONFIG_FN
-
-say "Ok, I've saved you up a nice lil' #{Redwood::CONFIG_FN}."
 
 done = false
 until done
@@ -210,6 +207,36 @@ until done
   end
 end
 
+say "\nSup needs to know where to store your sent messages."
+say "Only sources capable of storing mail will be listed.\n\n"
+
+index.load_sources
+if index.sources.empty?
+  say "\nUsing the default sup://sent, since you haven't configured other sources yet."
+  $config[:sent_source] = 'sup://sent'
+else
+  # this handles the event that source.yaml already contains the SentLoader
+  # source.
+  have_sup_sent = false
+
+  choose do |menu|
+    menu.prompt = "Store my sent mail in? "
+
+    valid_sents = index.sources.each do |s|
+      have_sup_sent = true if s.to_s.eql?('sup://sent')
+
+      menu.choice(s.to_s) { $config[:sent_source] = s.to_s } if s.respond_to? :store_message
+    end
+
+    menu.choice('Default (sup://sent)') { $config[:sent_source] = 'sup://sent'} unless have_sup_sent
+
+  end
+end
+
+Redwood::save_yaml_obj $config, Redwood::CONFIG_FN
+
+say "Ok, I've saved you up a nice lil' #{Redwood::CONFIG_FN}."
+
 say <<EOS
 
 Ok. The final step is to import all your messages into the Sup index.