74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
# File 'lib/sparrow/runner.rb', line 74
def parse_options
OptionParser.new do |opts|
opts.summary_width = 25
opts.banner = "Sparrow (#{VERSION})\n\n",
"Usage: sparrow [-b path] [-h host] [-p port] [-P file]\n",
" [-d] [-k port] [-l file] [-e]\n",
" sparrow --help\n",
" sparrow --version\n"
opts.separator ""
opts.separator ""; opts.separator "Configuration:"
opts.on("-b", "--base PATH", String, "Path to queue data store.", "(default: #{options[:base_dir]})") do |v|
options[:base_dir] = File.expand_path(v)
end
opts.separator ""; opts.separator "Network:"
opts.on("-h", "--host HOST", String, "Specify host", "(default: #{options[:host]})") do |v|
options[:host] = v
end
opts.on("-p", "--port PORT", Integer, "Specify port", "(default: #{options[:port]})") do |v|
options[:port] = v
end
opts.separator ""; opts.separator "Daemonization:"
opts.on("-P", "--pid FILE", String, "save PID in DIR when using -d option.", "(default: #{options[:pid_dir]})") do |v|
options[:pid_dir] = File.expand_path(v)
end
opts.on("-d", "--daemon", "Daemonize mode") do |v|
options[:daemonize] = v
end
opts.on("-k", "--kill", "Kill daemons on port #{options[:port]}.") do |v|
options[:kill] = v
end
opts.on("-j", "--kill-all", String, "Kill specified running daemons - leave blank to kill all.") do |v|
options[:kill_all] = v
end
opts.separator ""; opts.separator "Logging:"
opts.on("-l", "--log [FILE]", String, "Path to print debugging information.") do |v|
options[:log_path] = File.expand_path(v)
end
opts.on("-e", "--debug", "Run in debug mode", "(default: #{options[:debug]})") do |v|
options[:debug] = v
end
opts.separator ""; opts.separator "Miscellaneous:"
opts.on_tail("-?", "--help", "Display this usage information.") do
puts "#{opts}\n"
exit
end
opts.on_tail("-v", "--version", "Display version") do |v|
puts "Sparrow #{VERSION}"
exit
end
end.parse!
options
end
|