Object
# File lib/rack/server.rb, line 96 96: def handler_opts(options) 97: begin 98: info = [] 99: server = Rack::Handler.get(options[:server]) || Rack::Handler.default(options) 100: if server && server.respond_to?(:valid_options) 101: info << "" 102: info << "Server-specific options for #{server.name}:" 103: 104: has_options = false 105: server.valid_options.each do |name, description| 106: next if name.to_s.match(/^(Host|Port)[^a-zA-Z]/) # ignore handler's host and port options, we do our own. 107: info << " -O %-21s %s" % [name, description] 108: has_options = true 109: end 110: return "" if !has_options 111: end 112: info.join("\n") 113: rescue NameError 114: return "Warning: Could not find handler specified (#{options[:server] || 'default'}) to determine handler-specific options" 115: end 116: end
# File lib/rack/server.rb, line 6 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("-O", "--option NAME[=VALUE]", "pass VALUE to the server as option NAME. If no VALUE, sets it to true. Run '#{$0} -s SERVER -h' to get a list of options for SERVER") { |name| 52: name, value = name.split('=', 2) 53: value = true if value.nil? 54: options[name.to_sym] = value 55: } 56: 57: opts.on("-E", "--env ENVIRONMENT", "use ENVIRONMENT for defaults (default: development)") { |e| 58: options[:environment] = e 59: } 60: 61: opts.on("-D", "--daemonize", "run daemonized in the background") { |d| 62: options[:daemonize] = d ? true : false 63: } 64: 65: opts.on("-P", "--pid FILE", "file to store PID (default: rack.pid)") { |f| 66: options[:pid] = ::File.expand_path(f) 67: } 68: 69: opts.separator "" 70: opts.separator "Common options:" 71: 72: opts.on_tail("-h", "-?", "--help", "Show this message") do 73: puts opts 74: puts handler_opts(options) 75: 76: exit 77: end 78: 79: opts.on_tail("--version", "Show version") do 80: puts "Rack #{Rack.version} (Release: #{Rack.release})" 81: exit 82: end 83: end 84: 85: begin 86: opt_parser.parse! args 87: rescue OptionParser::InvalidOption => e 88: warn e.message 89: abort opt_parser.to_s 90: end 91: 92: options[:config] = args.last if args.last 93: options 94: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.