]> git.cworth.org Git - sup/commitdiff
Add a --query option to sup-tweak-labels.
authorNicolas Pouillard <nicolas.pouillard@gmail.com>
Fri, 14 Nov 2008 12:29:25 +0000 (13:29 +0100)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Thu, 20 Nov 2008 15:14:22 +0000 (07:14 -0800)
bin/sup-tweak-labels

index 21e766ce465e5ce8318e6032b54f24ccbe7abe96..4d1313eef08d8dbacdfba9a5475d4f8666489dd8 100644 (file)
@@ -39,6 +39,7 @@ Options:
 EOS
   opt :add, "One or more labels (comma-separated) to add to every message from the specified sources", :type => String
   opt :remove, "One or more labels (comma-separated) to remove from every message from the specified sources, if those labels are present", :type => String
+  opt :query, "A Sup search query", :type => String
 
   text <<EOS
 
@@ -76,6 +77,10 @@ begin
     ## query to only messages with those labels
     query += " +(" + remove_labels.map { |l| "label:#{l}" }.join(" ") + ")"
   end
+  query += ' ' + opts[:query] if opts[:query]
+
+  qobj, opts = Redwood::Index.parse_user_query_string query
+  query = Redwood::Index.build_query opts.merge(:qobj => qobj)
 
   results = index.ferret.search query, :limit => :all
   num_total = results.total_hits