8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/fakerest/argumentsparser.rb', line 8
def parse(args)
options = {}
optparse = OptionParser.new do |opts|
opts.banner = "Usage: fakerest.rb [options]"
options[:port] = 1111
options[:config] = nil
options[:views] = 'views'
options[:uploads] = 'uploads'
options[:bind] = 'localhost'
opts.on("-c","--config CONFIG_FILE","Confilg file to load request mappings (required)") do |cfg|
options[:config] = cfg
end
opts.on("-p","--port PORT","Port on which the fakerest to be run. Default = 1111") do |prt|
options[:port] = prt
end
opts.on("-o","--bind HOSTNAME/IP_ADDR","String specifying the hostname or IP address of the interface to listen on . Default = localhost") do |host|
options[:bind] = host
end
opts.on("-w","--views VIEWS_FOLDER","Folder path that contains the views. Default = <WORKING_DIR>/views") do |views|
options[:views] = views
end
opts.on("-u","--uploads UPLOADS_FOLDER","Folder to which any file uploads to be stored. Default = <WORKING_DIR>/uploads") do |uploads|
options[:uploads] = uploads
end
opts.on( "-h", "--help", "Displays help message" ) do
puts opts
exit
end
end
optparse.parse!(args)
if(options[:config] == nil)
puts optparse
exit(-1)
end
options
end
|