32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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
|
# File 'lib/alchemy/runner.rb', line 32
def parse_options
self.options = { :host => '127.0.0.1',
:port => 22122,
:path => File.join(%w( / var spool alchemy )),
:log_level => 0,
:daemonize => false,
:pid_file => File.join(%w( / var run alchemy.pid )) }
OptionParser.new do |opts|
opts.summary_width = 25
opts.banner = "alchemy (#{AlchemyServer::VERSION})\n\n",
"usage: alchemy [-v] [-q path] [-h host] [-p port]\n",
" [-d [-P pidfile]] [-u user] [-g group] [-l log]\n",
" alchemy --help\n",
" alchemy --version\n"
opts.separator ""
opts.separator "Configuration:"
opts.on("-q", "--list_path PATH",
:REQUIRED,
"Path to store alchemy list logs", "(default: #{options[:path]})") do |list_path|
options[:path] = list_path
end
opts.separator ""; opts.separator "Network:"
opts.on("-hHOST", "--host HOST", "Interface on which to listen (default: #{options[:host]})") do |host|
options[:host] = host
end
opts.on("-pHOST", "--port PORT", Integer, "TCP port on which to listen (default: #{options[:port]})") do |port|
options[:port] = port
end
opts.separator ""; opts.separator "Process:"
opts.on("-d", "Run as a daemon.") do
options[:daemonize] = true
end
opts.on("-PFILE", "--pid FILE", "save PID in FILE when using -d option.", "(default: #{options[:pid_file]})") do |pid_file|
options[:pid_file] = pid_file
end
opts.on("-u", "--user USER", Integer, "User to run as") do |user|
options[:user] = user
end
opts.on("-gGROUP", "--group GROUP", "Group to run as") do |group|
options[:group] = group
end
opts.separator ""; opts.separator "Logging:"
opts.on("-l", "--log [FILE]", "Path to print debugging information.") do |log_path|
options[:log] = log_path
end
opts.on("-v", "Increase logging verbosity.") do
options[:log_level] += 1
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", "Print version number and exit.") do
puts "alchemy #{AlchemyServer::VERSION}\n\n"
exit
end
end.parse!
end
|