Class: Vedeu::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/configuration.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = []) ⇒ Configuration

Returns a new instance of Configuration.



7
8
9
10
# File 'lib/vedeu/configuration.rb', line 7

def initialize(args = [])
  @args    = args
  @options = {}
end

Class Method Details

.configure(args = []) ⇒ Object



3
4
5
# File 'lib/vedeu/configuration.rb', line 3

def self.configure(args = [])
  new(args).configure
end

Instance Method Details

#configureObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/vedeu/configuration.rb', line 12

def configure
  parser = OptionParser.new do |opts|
    opts.banner = "Usage: #{$PROGRAM_NAME} [options]"

    opts.on('-1', '--run-once', 'Run application once.') do
      options[:interactive] = false
    end

    opts.on('-c', '--cooked', 'Run application in cooked mode.') do
      options[:mode] = :cooked
    end

    opts.on('-r', '--raw', 'Run application in raw mode (default).') do
      options[:mode] = :raw
    end

    opts.on('-d', '--debug', 'Run application with debugging on.') do
      options[:debug] = true
    end
  end
  parser.parse!(args)

  options
end