5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/fluke/cli.rb', line 5
def self.execute(stdout, stderr, arguments=[])
p = {
:stdout => stdout, :stderr => stderr
}
parser = OptionParser.new do |opts|
opts.banner = " A simple resource observer designed to detect change over time.\n\n Usage: \#{File.basename($0)} [options]\n # run all watchers\n\n -OR-\n\n \#{File.basename($0)} [options] arg1..argN\n # args are either files, in which case watcher info is\n # inferred based on file content, or watcher names\n Options are:\n BANNER\n opts.separator \"\"\n opts.on(\"-c\", \"--conf\", String,\n \"Config file location\",\n \"Default: \#{Fluke::DEFAULT_CONF_PATH}\") { |arg| p[:conf_path] = arg || nil }\n opts.on(\"-v\", \"--verbose\",\n \"Be chatty.\",\n \"Default: false\") { |arg| Fluke.verbose = arg }\n opts.on(\"-h\", \"--help\",\n \"Show this help message.\") { stderr.puts opts; exit }\n opts.parse!(arguments)\n end\n\n Fluke.configure! p\n\n if arguments.size > 0 then\n arguments.uniq.each do |name|\n if File.exists?(name) and !File.directory?(name) then\n path = File.expand_path(name)\n Fluke.class_eval(File.read(path), path)\n else\n Fluke.watch name\n end\n end\n else\n Watcher.find(:all).each do |watcher|\n Fluke.watch watcher\n end\n end\n\n Fluke.run!\nend\n".gsub(/^ /,'')
|