6: def parse!(args)
7: options = {}
8: opt_parser = OptionParser.new("", 24, ' ') do |opts|
9: opts.banner = "Usage: rackup [ruby options] [rack options] [rackup config]"
10:
11: opts.separator ""
12: opts.separator "Ruby options:"
13:
14: lineno = 1
15: opts.on("-e", "--eval LINE", "evaluate a LINE of code") { |line|
16: eval line, TOPLEVEL_BINDING, "-e", lineno
17: lineno += 1
18: }
19:
20: opts.on("-d", "--debug", "set debugging flags (set $DEBUG to true)") {
21: options[:debug] = true
22: }
23: opts.on("-w", "--warn", "turn warnings on for your script") {
24: options[:warn] = true
25: }
26:
27: opts.on("-I", "--include PATH",
28: "specify $LOAD_PATH (may be used more than once)") { |path|
29: options[:include] = path.split(":")
30: }
31:
32: opts.on("-r", "--require LIBRARY",
33: "require the library, before executing your script") { |library|
34: options[:require] = library
35: }
36:
37: opts.separator ""
38: opts.separator "Rack options:"
39: opts.on("-s", "--server SERVER", "serve using SERVER (webrick/mongrel)") { |s|
40: options[:server] = s
41: }
42:
43: opts.on("-o", "--host HOST", "listen on HOST (default: 0.0.0.0)") { |host|
44: options[:Host] = host
45: }
46:
47: opts.on("-p", "--port PORT", "use PORT (default: 9292)") { |port|
48: options[:Port] = port
49: }
50:
51: opts.on("-E", "--env ENVIRONMENT", "use ENVIRONMENT for defaults (default: development)") { |e|
52: options[:environment] = e
53: }
54:
55: opts.on("-D", "--daemonize", "run daemonized in the background") { |d|
56: options[:daemonize] = d ? true : false
57: }
58:
59: opts.on("-P", "--pid FILE", "file to store PID (default: rack.pid)") { |f|
60: options[:pid] = f
61: }
62:
63: opts.separator ""
64: opts.separator "Common options:"
65:
66: opts.on_tail("-h", "--help", "Show this message") do
67: puts opts
68: exit
69: end
70:
71: opts.on_tail("--version", "Show version") do
72: puts "Rack #{Rack.version}"
73: exit
74: end
75: end
76: opt_parser.parse! args
77: options[:config] = args.last if args.last
78: options
79: end