# File lib/camping/server.rb, line 42
42:       def parse!(args)
43:         args = args.dup
44:         options = {}
45:         
46:         opt_parser = OptionParser.new("", 24, '  ') do |opts|
47:           opts.banner = "Usage: camping app1.rb app2.rb..."
48:           opts.define_head "#{File.basename($0)}, the microframework ON-button for ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
49:           opts.separator ""
50:           opts.separator "Specific options:"
51:           
52:           opts.on("-h", "--host HOSTNAME",
53:           "Host for web server to bind to (default is all IPs)") { |v| options[:Host] = v }
54:           
55:           opts.on("-p", "--port NUM",
56:           "Port for web server (defaults to 3301)") { |v| options[:Port] = v }
57:           
58:           db = DB.sub(HOME, '~/') if DB
59:           opts.on("-d", "--database FILE",
60:           "SQLite3 database path (defaults to #{db ? db : '<none>'})") { |db_path| options[:database] = db_path }
61:           
62:           opts.on("-C", "--console",
63:           "Run in console mode with IRB") { options[:server] = "console" }
64:           
65:           server_list = ["mongrel", "webrick", "console"]
66:           opts.on("-s", "--server NAME",
67:           "Server to force (#{server_list.join(', ')})") { |v| options[:server] = v }
68: 
69:           opts.separator ""
70:           opts.separator "Common options:"
71:           
72:           # No argument, shows at tail.  This will print an options summary.
73:           # Try it and see!
74:           opts.on_tail("-?", "--help", "Show this message") do
75:             puts opts
76:             exit
77:           end
78: 
79:           # Another typical switch to print the version.
80:           opts.on_tail("-v", "--version", "Show version") do
81:             puts Gem.loaded_specs['camping'].version
82:             exit
83:           end
84:         end
85:         
86:         opt_parser.parse!(args)
87:         
88:         if args.empty?
89:           puts opt_parser
90:           exit
91:         end
92:         
93:         options[:scripts] = args
94:         options
95:       end