Class: Baya::Configuration::CommandLine

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/baya/configuration/command_line.rb

Constant Summary collapse

DEFAULTS =
{
  'config' => 'baya.json'
}

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CommandLine

Returns a new instance of CommandLine.



13
14
15
16
17
18
19
# File 'lib/baya/configuration/command_line.rb', line 13

def initialize(args)
  super
  DEFAULTS.each do |k, v|
    self.send(:"#{k}=", v)
  end
  opts.parse(args)
end

Instance Method Details

#optsObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/baya/configuration/command_line.rb', line 21

def opts
  @opts ||= OptionParser.new do |opts|
    opts.on("-c", "--config CONFIG",
            "Set path to the configuration file") do |config|
      self.config = config
    end
    opts.on_tail("-v", "--version", "Show version") do
      self.version = true
    end
    opts.on_tail("-h", "--help", "Show help") do
      self.help = true
    end
  end
end