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
|
# File 'lib/execution.rb', line 8
def threadexec(command, prefix = nil, color = nil)
unless prefix.nil?
prefix = "#{prefix} | "
end
if color.nil?
color = :cyan
end
Thread.new {
Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
while lineOut = stdout.gets
puts prefix.nil? ? lineOut : prefix.colorize(color) + lineOut
end
while lineErr = stderr.gets
puts prefix.nil? ? lineErr : prefix.colorize(color) + lineErr
end
end
}
end
|