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
|
# File 'lib/stubify.rb', line 11
def run
program :name, 'stubify'
program :version, Stubify::VERSION
program :description, Stubify::DESCRIPTION
program :help, 'Author', 'Carlos Vidal <[email protected]>'
command :server do |c|
c.syntax = 'server [options]'
c.description = 'Runs a local environment that will forward the requests received to the host provided. Responses will be cached'
c.option '--host STRING', String, 'Host the requests will be redirected to. i.e. https://easy-peasy.io'
c.option '--port STRING', String, 'Port the local environment will listen to. Default is 4567'
c.option '--directory DIR', String, 'Path where fixtures will be stored. i.e. fixtures/'
c.option '--whitelist DIR', String, 'Path to the .yaml file with the whitelisted paths'
c.option '--verbose', 'Increases the amount of information logged'
c.action do |args, options|
if options.host.nil?
raise 'Host must be provided. Run help command for more details'
end
options.default \
port: '4567',
directory: 'fixtures',
verbose: false,
whitelisted: parse_whitelist(options.whitelist)
ENV['PORT'] = options.port
Stubify.options = options
require 'stubify/server'
end
end
run!
end
|