Class: Cherrybase::Cmd

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

Instance Method Summary collapse

Instance Method Details

#run(command = '', show_lines = false) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cmd.rb', line 7

def run(command = '', show_lines = false)
  if DEBUG
    puts "[Cmd::run] #{command}"
  end
  lines = []
  Open3.popen3(command) { |stdin, stdout, stderr| lines = stdout.readlines }
  if DEBUG || show_lines
    lines.each do |line|
      puts line
    end
  end
  lines
end