Class: LitmusPaper::CLI::Server::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/litmus_paper/cli/server.rb

Instance Method Summary collapse

Instance Method Details

#parse!(args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/litmus_paper/cli/server.rb', line 5

def parse!(args)
  args, options = args.dup, {}
  options[:unicorn_config] = "/etc/litmus_unicorn.rb"
  options[:daemonize] = false
  options[:Host] = "0.0.0.0"
  options[:Port] = 9293

  opt_parser = OptionParser.new do |opts|
    opts.banner = "Usage: litmus [options]"
    opts.separator ""

    opts.on("-b", "--binding=ip", String,
            "Binds Litmus to the specified ip.", "Default: 0.0.0.0") { |v| options[:Host] = v }
    opts.on("-d", "--daemon", "Make server run as a Daemon.") { |d| options[:daemonize] = true }
    opts.on("-p", "--port=port", "Listen Port") { |p| options[:Port] = p }
    opts.on("-c", "--unicorn-config=config", "Unicorn Config") { |c| options[:unicorn_config] = c }

    opts.separator ""

    opts.on("-h", "--help", "Show this help message.") { puts opts; exit }
  end

  opt_parser.parse! args

  options
end