Method: Beaker::CLI#parse_options

Defined in:
lib/beaker/cli.rb

#parse_options(args = ARGV) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/beaker/cli.rb', line 22

def parse_options(args = ARGV)
  @options_parser = Beaker::Options::Parser.new
  @options = @options_parser.parse_args(args)
  @attribution = @options_parser.attribution
  @logger = Beaker::Logger.new(@options)
  InParallel::InParallelExecutor.logger = @logger
  @options_parser.update_option(:logger, @logger, 'runtime')
  @options_parser.update_option(:timestamp, @timestamp, 'runtime')
  @options_parser.update_option(:beaker_version, Beaker::Version::STRING, 'runtime')
  beaker_version_string = VERSION_STRING % @options[:beaker_version]

  # Some flags should exit early
  if @options[:help]
    @logger.notify(@options_parser.usage)
    exit(0)
  end
  if @options[:beaker_version_print]
    @logger.notify(beaker_version_string)
    exit(0)
  end
  if @options[:parse_only]
    print_version_and_options
    exit(0)
  end

  #add additional paths to the LOAD_PATH
  if not @options[:load_path].empty?
    @options[:load_path].each do |path|
      $LOAD_PATH << File.expand_path(path)
    end
  end
  @options[:helper].each do |helper|
    require File.expand_path(helper)
  end

  self
end