Class: Bowler::CLI

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

Class Method Summary collapse

Class Method Details

.build_command(launch_string) ⇒ Object



50
51
52
# File 'lib/bowler/cli.rb', line 50

def self.build_command(launch_string)
  "#{self.foreman_exec} start -c #{launch_string}"
end

.loggerObject



42
43
44
# File 'lib/bowler/cli.rb', line 42

def self.logger
  @@logger ||= Logger.new(STDOUT)
end

.logger=(logger) ⇒ Object



46
47
48
# File 'lib/bowler/cli.rb', line 46

def self.logger=(logger)
  @@logger = logger
end

.start(args) ⇒ Object



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
37
38
39
40
# File 'lib/bowler/cli.rb', line 7

def self.start(args)
  options = {
    without: []
  }
  OptionParser.new {|opts|
    opts.banner = "Usage: bowl [options] <process>..."

    opts.on('-w', '--without <process>', 'Exclude a process from being launched') do |process|
      options[:without] << process.to_sym
    end

    opts.on_tail("-h", "--help", "Show this message") do
      puts opts
      exit
    end

    opts.on_tail('-v', '--version', 'Show the gem version') do
      puts "Bowler #{Bowler::VERSION}"
      exit
    end
  }.parse!(args)

  processes = args.map(&:to_sym)

  tree = Bowler::DependencyTree.load
  to_launch = tree.dependencies_for(processes) - options[:without]
  logger.info "Starting #{to_launch.join(', ')}.."

  start_foreman_with( launch_string(to_launch) )
rescue PinfileNotFound
  logger.error "Bowler could not find a Pinfile in the current directory."
rescue PinfileError => e
  logger.error "Bowler could not load the Pinfile due to an error: #{e}"
end