Class: Foreman::CLI

Inherits:
Thor
  • Object
show all
Includes:
Helpers
Defined in:
lib/foreman/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#classify, #constantize

Class Method Details

.is_thor_reserved_word?(word, type) ⇒ Boolean

Hackery. Take the run method away from Thor so that we can redefine it.

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/foreman/cli.rb', line 24

def is_thor_reserved_word?(word, type)
  return false if word == 'run'
  super
end

Instance Method Details

#checkObject



56
57
58
59
60
# File 'lib/foreman/cli.rb', line 56

def check
  check_procfile!
  error "no processes defined" unless engine.procfile.entries.length > 0
  puts "valid procfile detected (#{engine.procfile.process_names.join(', ')})"
end

#export(format, location = nil) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/foreman/cli.rb', line 46

def export(format, location=nil)
  check_procfile!
  formatter = Foreman::Export.formatter(format)
  formatter.new(location, engine, options).export
rescue Foreman::Export::Exception => ex
  error ex.message
end

#run(*args) ⇒ Object



64
65
66
67
68
69
70
71
72
73
# File 'lib/foreman/cli.rb', line 64

def run(*args)
  engine.apply_environment!
  begin
    exec args.join(" ")
  rescue Errno::EACCES
    error "not executable: #{args.first}"
  rescue Errno::ENOENT
    error "command not found: #{args.first}"
  end
end

#start(process = nil) ⇒ Object



30
31
32
33
34
# File 'lib/foreman/cli.rb', line 30

def start(process=nil)
  check_procfile!
  engine.options[:concurrency] = "#{process}=1" if process
  engine.start
end