Class: Brewmaster::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/brewmaster/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CLI



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/brewmaster/cli.rb', line 5

def initialize(args)
  options = {}

  @name = 'brewmaster'

  OptionParser.new do |parser|
    parser.banner = [
      "Usage: #{@name} [--bootstrap] [-c config_file]\n",
      "       #{@name} --help\n"
    ].compact.join

    parser.on('-c', '--config FILE') do |path|
      options[:config_path] = path
    end

    parser.on('--bootstrap') do
      options[:bootstrap] = true
    end

    # parser.on("-l", "--log FILE") do |path|
    #   options[:log_path] = path
    # end

    parser.on_tail("-?", "--help", "Display this usage information.") do
      puts "#{parser}\n"
      exit
    end
  end.parse!(args)

  self.configuration = Configuration.new(options)
  self.coordinator = Coordinator.new(configuration)
end

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



3
4
5
# File 'lib/brewmaster/cli.rb', line 3

def configuration
  @configuration
end

#coordinatorObject

Returns the value of attribute coordinator.



3
4
5
# File 'lib/brewmaster/cli.rb', line 3

def coordinator
  @coordinator
end

Instance Method Details

#runObject



38
39
40
# File 'lib/brewmaster/cli.rb', line 38

def run
  coordinator.run
end