Sha256: 54ec0a921a703e35f64199ef93197a44ebb0bf60fccb2a668ee28d6811b102e6
Contents?: true
Size: 1.1 KB
Versions: 33
Compression:
Stored size: 1.1 KB
Contents
require 'open3' require 'thor/shell' module Execution Thread.abort_on_exception = true def threadexec(command, prefix = nil, color = nil) if prefix.nil? # TODO: probably pick the command name without args prefix = 'unknown' end if color.nil? color = :cyan end Thread.new { Open3.popen3(command) do |_, stdout, stderr, _| # noinspection RubyAssignmentExpressionInConditionalInspection while line_out = stdout.gets say_status prefix, line_out, color end # noinspection RubyAssignmentExpressionInConditionalInspection while line_err = stderr.gets say_status prefix, line_err, :red end end } end # unison doesn't work when ran in a new thread # this functions creates a full new process instead def forkexec(command, prefix = nil, color = nil) if prefix.nil? # TODO: probably pick the command name without args prefix = 'unknown' end if color.nil? color = :cyan end Process.fork { `#{command}` || raise(command + ' failed') } end end
Version data entries
33 entries across 33 versions & 1 rubygems