Class: Rhino::CLI

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

Overview

A wrapper for command line interaction that encompasses option parsing, version, help, and execution.

Usage:

cli = Rhino::CLI.new
cli.parse

Constant Summary collapse

"usage: rhino [options] [./config.ru]".freeze

Instance Method Summary collapse

Instance Method Details

#parse(items = ARGV) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rhino/cli.rb', line 13

def parse(items = ARGV)
  config = Slop.parse(items) do |options|
    options.banner = BANNER

    options.on "-h", "--help", "help" do
      return help(options)
    end

    options.on "-v", "--version", "version" do
      return version
    end

    options.string "-b", "--bind", "bind (default: 0.0.0.0)", default: "0.0.0.0"
    options.integer "-p", "--port", "port (default: 5000)", default: 5000
    options.integer "--backlog", "backlog (default: 64)", default: 64
    options.boolean "--reuseaddr", "reuseaddr (default: true)", default: true
  end

  run(config)
end