Class: Jax::Server::Options

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

Instance Method Summary collapse

Instance Method Details

#parse!(args) ⇒ Object



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
55
56
57
58
59
60
# File 'lib/jax/server.rb', line 30

def parse!(args)
  args, options = args.dup, {}

  opt_parser = OptionParser.new do |opts|
    opts.banner = "Usage: jax server [mongrel, thin, etc] [options]"
    opts.on("-p", "--port=port", Integer,
            "Runs Jax on the specified port.", "Default: 3000") { |v| options[:Port] = v }
    opts.on("-b", "--binding=ip", String,
            "Binds Jax to the specified ip.", "Default: 0.0.0.0") { |v| options[:Host] = v }
    opts.on("-c", "--config=file", String,
            "Use custom rackup configuration file") { |v| options[:config] = v }
    opts.on("-d", "--daemon", "Make server run as a Daemon.") { options[:daemonize] = true }
    opts.on("-u", "--debugger", "Enable ruby-debugging for the server.") { options[:debugger] = true }
    opts.on("-e", "--environment=name", String,
            "Specifies the environment to run this server under (test/development/production).",
            "Default: development") { |v| options[:environment] = v }
    opts.on("-P","--pid=pid",String,
            "Specifies the PID file.",
            "Default: tmp/pids/server.pid") { |v| options[:pid] = v }
    opts.on('-q','--quiet',"Does not tail the log file.") { |v| options[:quiet] = true }

    opts.separator ""

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

  opt_parser.parse! args
  options[:server] = args.shift

  options
end