lib/rerun/options.rb in rerun-0.9.0 vs lib/rerun/options.rb in rerun-0.10.0

- old
+ new

@@ -1,22 +1,24 @@ require 'optparse' require 'pathname' +require 'rerun/watcher' libdir = "#{File.expand_path(File.dirname(File.dirname(__FILE__)))}" $spec = Gem::Specification.load(File.join(libdir, "..", "rerun.gemspec")) module Rerun class Options - DEFAULT_PATTERN = "**/*.{rb,js,css,scss,sass,erb,html,haml,ru}" + DEFAULT_PATTERN = "**/*.{rb,js,coffee,css,scss,sass,erb,html,haml,ru,yml,slim,md}" DEFAULT_DIRS = ["."] DEFAULTS = { :pattern => DEFAULT_PATTERN, :signal => "TERM", :growl => true, - :name => Pathname.getwd.basename.to_s.capitalize + :name => Pathname.getwd.basename.to_s.capitalize, + :ignore => [] } def self.parse args = ARGV options = DEFAULTS.dup opts = OptionParser.new("", 24, ' ') do |opts| @@ -32,15 +34,20 @@ opts.on("-d dir", "--dir dir", "directory to watch, default = \"#{DEFAULT_DIRS}\". Specify multiple paths with ',' or separate '-d dir' option pairs.") do |dir| elements = dir.split(",") options[:dir] = (options[:dir] || []) + elements end - opts.on("-p pattern", "--pattern pattern", "file glob, default = \"#{DEFAULTS[:pattern]}\"") do |pattern| + # todo: rename to "--watch" + opts.on("-p pattern", "--pattern pattern", "file glob to watch, default = \"#{DEFAULTS[:pattern]}\"") do |pattern| options[:pattern] = pattern end - opts.on("-s", "--signal signal", "terminate process using this signal, default = \"#{DEFAULTS[:signal]}\"") do |signal| + opts.on("-i pattern", "--ignore pattern", "file glob to ignore (can be set many times). To ignore a directory, you must append '/*' e.g. --ignore 'coverage/*'") do |pattern| + options[:ignore] += [pattern] + end + + opts.on("-s signal", "--signal signal", "terminate process using this signal, default = \"#{DEFAULTS[:signal]}\"") do |signal| options[:signal] = signal end opts.on("-c", "--clear", "clear screen before each run") do options[:clear] = true @@ -71,10 +78,10 @@ puts $spec.version return end opts.on_tail "" - opts.on_tail "On top of --pattern, we ignore any changes to files and dirs starting with a dot, ending with [#{Listen::Silencer::DEFAULT_IGNORED_EXTENSIONS.join(',')}], or named [#{Listen::Silencer::DEFAULT_IGNORED_DIRECTORIES.join(',')}]." + opts.on_tail "On top of --pattern and --ignore, we ignore any changes to files and dirs starting with a dot." end if args.empty? puts opts