Class: Buffet::CLI

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

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CLI

Returns a new instance of CLI.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/buffet/cli.rb', line 6

def initialize args
  opts = OptionParser.new do |opts|
    opts.banner = "Usage: buffet [options] [spec-files]"

    opts.on('-c', '--config CONFIG',
            'Use the specified CONFIG file') do |config_file|
      Settings.load_file File.expand_path(config_file)
    end

    opts.on('-p', '--project PROJECT',
            'Use the specified PROJECT name') do |project_name|
      Settings.project_name = project_name
    end
  end.parse!(args)

  specs = Buffet.extract_specs_from(opts.empty? ? 'spec' : opts)

  runner = Runner.new
  runner.run specs

  exit 1 if runner.failures?
end