Sha256: 1ca34292d7810396db4292dcf458975ec43877178593e713890de72377ecf0de
Contents?: true
Size: 1.93 KB
Versions: 1
Compression:
Stored size: 1.93 KB
Contents
require 'optparse' require 'jubilee' require 'java' module Jubilee class CLI # Parsed options attr_accessor :options def initialize(argv) @argv = argv setup_options end def parse_options @parser.parse! @argv if @argv.last @options[:rackup] = @argv.shift end end def run parse_options @config = Jubilee::Configuration.new(@options) @config.load server = Jubilee::Server.new(@config.app, {port: @config.port, ssl: @config.ssl}) server.start puts "Jubilee is listening on port #{@config.port}, press Ctrl+C to quit" starter = org.jruby.jubilee.deploy.Starter.new starter.block end def setup_options @options = { debug: false, daemon: false, port: 3215, ssl: false, environment: "development" } @parser = OptionParser.new do |o| #o.on "-c", "--config PATH", "Load PATH as a config file" do |arg| # @options[:config_file] = arg #end #o.on "-d", "--daemon", "Daemonize the server" do # @options[:daemon] = true #end o.on "--dir DIR", "Change to DIR before starting" do |arg| @options[:chdir] = arg end o.on "-p", "--port PORT", "Defind which PORT the server should bind" do |arg| @options[:port] = arg end o.on "--ssl", "Enable SSL connection" do @options[:ssl] = true end o.on "--verbose", "Log low level debug information" do @options[:debug] = true end o.on "-e", "--environment ENV", "Rack environment" do |arg| @options[:environment] = arg end o.on "-q", "--quiet" do @options[:quiet] = true end end @parser.banner = "jubilee <options> <rackup file>" @parser.on_tail "-h", "--help", "Show this message" do puts @parser exit 1 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jubilee-0.1.2 | lib/jubilee/cli.rb |