class Servethis2::CLI

Public Class Methods

run() click to toggle source
# File lib/servethis2/cli.rb, line 37
def self.run
  self.new.run
end

Public Instance Methods

default_options() click to toggle source
# File lib/servethis2/cli.rb, line 7
def default_options
  {
    :Port => 8000,
    :DocumentRoot => ".",
    :ServerSoftware => "Servethis2/#{Servethis2::VERSION} " +
                        "(Ruby/#{RUBY_VERSION}/#{RUBY_RELEASE_DATE})"
  }
end
options() click to toggle source
# File lib/servethis2/cli.rb, line 16
def options
  @options ||= default_options
end
optparse!() click to toggle source
# File lib/servethis2/cli.rb, line 20
def optparse!
  OptionParser.new do |opts|
    opts.banner = "Usage: #{$0} [doc_root] [-p port]"

    opts.on("-p", "--port PORT", "Use specified port") do |p|
      options[:Port] = p
    end
  end.parse!

  options[:DocumentRoot] = ARGV[0] if ARGV[0]
end
run() click to toggle source
# File lib/servethis2/cli.rb, line 32
def run
  optparse!
  Server.new(options).start
end