Sha256: d96c22c0c5d9c705a52d21e8f1725f1ca8614c8a8686c8283a64f32e08f98593
Contents?: true
Size: 1.26 KB
Versions: 3
Compression:
Stored size: 1.26 KB
Contents
require 'reel/rack' require 'optparse' module Reel module Rack class CLI def initialize(argv) @argv = argv @options = { addr: "localhost", port: 3000, quiet: false, rackup: "config.ru" } parser end def parser @parser ||= OptionParser.new do |o| o.banner = "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 def run @parser.parse! @argv @options[:rackup] = @argv.shift if @argv.last app, options = ::Rack::Builder.parse_file(@options[:rackup]) options.merge!(@options) ::Rack::Handler::Reel.run(app, options) Celluloid.logger.info "That's all, folks!" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
reel-rack-0.0.2 | lib/reel/rack/cli.rb |
reel-rack-0.0.1 | lib/reel/rack/cli.rb |
reel-rack-0.0.1.pre2 | lib/reel/rack/cli.rb |