Module: Options

Defined in:
lib/options.rb

Class Method Summary collapse

Class Method Details

.parse!Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/options.rb', line 4

def self.parse!
  options = OpenStruct.new host: "localhost", port: 3000,
                       start_at: 0

  OptionParser.new do |opts|
    opts.on("-h", "--host_name=val", String)  { |arg| options.host     = arg }
    opts.on("-p", "--port=val",      Integer) { |arg| options.port     = arg }
    opts.on("-s", "--start_at=",     Integer) { |arg| options.start_at = arg }
    opts.on("", "--help")                     { exec "more #{__FILE__}"      }
  end.parse!
  options
end