bin/sup-tweak-labels in sup-0.6 vs bin/sup-tweak-labels in sup-0.7
- old
+ new
@@ -37,10 +37,11 @@
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
Other options:
EOS
@@ -74,9 +75,13 @@
if add_labels.empty?
## if all we're doing is removing labels, we can further restrict the
## 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
$stderr.puts "Found #{num_total} documents across #{source_ids.length} sources. Scanning..."