Class: Reel::Rack::CLI
- Inherits:
-
Object
- Object
- Reel::Rack::CLI
- Defined in:
- lib/reel/rack/cli.rb
Instance Method Summary collapse
-
#initialize(argv) ⇒ CLI
constructor
A new instance of CLI.
- #parser ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ CLI
Returns a new instance of CLI.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/reel/rack/cli.rb', line 7 def initialize(argv) @argv = argv @options = { addr: "localhost", Port: 3000, quiet: false, rackup: "config.ru" } parser end |
Instance Method Details
#parser ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/reel/rack/cli.rb', line 18 def parser @parser ||= OptionParser.new do |o| o. = "reel-rack <options> <rackup file>" o.on "-a", "--addr ADDR", "Address to listen on (default #{@options[:addr]})" do |addr| @options[:addr] = addr end o.on "-p", "--port PORT", "Port to bind to (default #{@options[:Port]})" do |port| @options[:Port] = port end o.on "-q", "--quiet", "Suppress normal logging output" do @options[:quiet] = true end o.on_tail "-h", "--help", "Show help" do STDOUT.puts @parser exit 1 end end end |
#run ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/reel/rack/cli.rb', line 41 def run @parser.parse! @argv @options[:rackup] = @argv.shift if @argv.last app, = ::Rack::Builder.parse_file(@options[:rackup]) .merge!(@options) ::Rack::Handler::Reel.run(app, ) Celluloid.logger.info "That's all, folks!" end |