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
|
# File 'lib/camping/server.rb', line 32
def parse!(args)
args = args.dup
options = {}
opt_parser = OptionParser.new("", 24, ' ') do |opts|
opts.banner = "Usage: camping Or: camping my-camping-app.rb"
opts.separator ""
opts.separator "Specific options:"
opts.on("-h", "--host HOSTNAME",
"Host for web server to bind to (default is all IPs)") { |v| options[:Host] = v }
opts.on("-p", "--port NUM",
"Port for web server (defaults to 3301)") { |v| options[:Port] = v }
opts.on("-c", "--console",
"Run in console mode with IRB") { options[:server] = "console" }
opts.on("-e", "--env ENVIRONMENT",
"Sets the environment. (defaults: development)") { |v| options[:environment] = ENV['environment'] = v }
server_list = ["thin", "webrick", "console", "puma", "tipi", "falcon"]
opts.on("-s", "--server NAME",
"Server to force (#{server_list.join(', ')})") { |v| options[:server] = v }
opts.separator ""
opts.separator "Common options:"
opts.on("-?", "--help", "Show this message") do
puts opts
exit
end
opts.on("-v", "--version", "Show version") { options[:version] = true }
opts.on("-r", "--routes", "Show Routes") { options[:routes] = true }
end
opt_parser.parse!(args)
if args.empty?
args << "camp.rb"
end
options[:script] = args.shift
options
end
|