Class: Caterer::Command::Berks

Inherits:
Base
  • Object
show all
Defined in:
lib/caterer/command/berks.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #parse_options

Constructor Details

This class inherits a constructor from Caterer::Command::Base

Instance Method Details

#executeObject



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

def execute
  options = {}
  parser = OptionParser.new do |opts|
    opts.banner = "Usage: cater berks install|update|clean"
  end

  # Parse the options
  argv = parse_options(parser, true)
  return if not argv

  case argv.first
  when 'install'
    run_action :berks_install
  when 'update'
    run_action :berks_install, {force_berks_install: true}
  when 'clean'
    run_action :berks_clean, {force_berks_clean: true}
  else
    safe_puts(parser.help)
  end

  0
end

#run_action(name, options = nil) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/caterer/command/berks.rb', line 29

def run_action(name, options=nil)
  options = {
    :ui => @env.ui,
    :config => @env.config
  }.merge(options || {})

  @env.action_runner.run(name, options)
end