Class: Options

Inherits:
Object
  • Object
show all
Defined in:
lib/directory_monitor/options.rb

Class Method Summary collapse

Class Method Details

.parseObject

Use trollop to handle all our options switches and verify we have some sort of shell-command specified on the command-line.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/directory_monitor/options.rb', line 41

def self.parse
  opts = Trollop::options do
    version "#{Version}"
    banner Banner.gsub(/^#{Banner[/^ +/, 0]}/, "")
    opt :suffix,  "Regex selecting the files being watched",  :default => ".*"
    opt :delay,   "Seconds to sleep between watches",         :default => 5.0
    opt :loop,    "Execute individual command for each file"
    opt :force,   "Force a first exectuion on all watched files"
    opt :token,   "String used for file name substitution",   :default => "%%"
    opt :verbose, "Print command on standard output",         :short => "V"
  end
  Trollop::die "shell command is required" if ARGV.empty?
  opts[:shell_command] = ARGV.join(" ")
  opts
end