#!/usr/bin/ruby -w # # Gmail supports filters, but the interface provided doesn't make it appear # to support filtering multiple addresses at the same time. It does, # and given multiple addresses, this script will return a filter string # that matches multiple sources. # # Author: Robert Peaslee # ...I know the multiple exit points are bad style, but this was quick. # if $*.length < 3 p "Usage: filters.rb ..." exit( 1 ) end case $*[0] when "from" # Get rid of first element $*.shift string = "from:(" $*.each { |addr| string << "#{addr}) OR from:(" } string.slice!( -8, string.length ) p "Copy this into the filter:" p "#{string}" exit( 0 ) when "to" # Get rid of first element $*.shift string = "to:(" $*.each { |addr| string << "#{addr}) OR to:(" } string.slice!( -8, string.length ) p "Copy this into the filter:" p "#{string}" exit( 0 ) else p "Please supply either from or to as the first argument." exit( 1 ) end