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
|
# File 'lib/deadpool/options.rb', line 15
def parse_command_line(argv)
options = {}
options[:config_path] = '/etc/deadpool'
options[:daemonize] = nil
@option_parser = OptionParser.new do |opts|
opts.banner = "Usage: deadpool_hosts {help|full_report|nagios_report} [options]"
opts.separator "Commands:"
opts.on("-h", "--help", "Print this help message.") do |help|
options[:help] = true
end
opts.on("-d", "--daemon", "Background the server.") do |daemon|
options[:daemonize] = true
end
opts.separator "Options:"
opts.on("--config_path=PATH", String,
"Path to configs and custom plugins. #{options[:config_path]} by default.") do |config_path|
options[:config_path] = config_path
end
end
remaining_arguments = @option_parser.parse! argv
unless remaining_arguments.empty?
help "[#{remaining_arguments.join(' ')}] is not understood."
end
return options
end
|