def initialize
@ruby_options = {}
@rack_options = {}
@options = OptionParser.new do |opt|
opt.banner = Banner
opt.summary_indent = ' '
opt.separator "\nRuby Options:\n"
opt.on('-e', '--eval LINE', 'Evaluates a line of code') do |code|
@ruby_options['-e'] = code
end
opt.on('-d', '--debug', 'Set debugging flags (set $DEBUG to true)') do
@ruby_options['-d'] = nil
end
opt.on('-w', '--warn', 'Turns warnings on for the script') do
@ruby_options['-w'] = nil
end
opt.on('-I', '--include PATH', 'specifies the $LOAD_PATH') do |path|
@ruby_options['-I'] = path
end
opt.on(
'-r',
'--require LIBRARY',
'requires the library before starting'
) do |library|
@ruby_options['-r'] = library
end
opt.separator "\nRack Options:\n"
opt.on(
'-s',
'--server SERVER',
'Serve the application using the given server'
) do |server|
@rack_options['-s'] = server
end
opt.on(
'-o',
'--host HOST',
'Listens on the given host (0.0.0.0 by default)'
) do |host|
@rack_options['-o'] = host
end
opt.on(
'-p',
'--port PORT',
'Uses the given port, set to 9292 by default'
) do |port|
@rack_options['-p'] = port
end
opt.on(
'-O',
'--option NAME[=VALUE]',
'Passes the given option and it\'s value to the server'
) do |name|
@rack_options['-O'] = name
end
opt.on(
'-E',
'--env ENVIRONMENT',
'Uses the specified environment, set to development by default'
) do |env|
@rack_options['-E'] = env
end
opt.on('-D', '--daemonize', 'Runs as a daemon in the background') do
@rack_options['-D'] = nil
end
opt.on(
'-P',
'--pid FILE',
'File to store the PID in, defaults to rack.pid'
) do |pid|
@rack_options['-P'] = pid
end
opt.separator "\nOptions\n"
opt.on('-h', '--help', 'Shows this help message') do
puts @options
exit
end
end
end