Module: Rtasklib::Execute
Overview
How to execute shell commands and capture output
Constant Summary collapse
- @@exp_regex =
{ create_rc: %r{Would \s you \s like \s a \s sample \s *.+ \s created, \s so \s taskwarrior \s can \s proceed\? \s \(yes/no\)}x }
Instance Method Summary collapse
- #each_popen3(program = 'task', *opts, &block) ⇒ Object
- #handle_response(stderr, thread) ⇒ Object
-
#popen3(program = 'task', *opts, &block) ⇒ Object
popen versions.
- #task_each_popen3(*opts, &block) ⇒ Object
- #task_popen3(*opts, &block) ⇒ Object
Instance Method Details
#each_popen3(program = 'task', *opts, &block) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/rtasklib/execute.rb', line 32 def each_popen3 program='task', *opts, &block popen3(program, *opts) do |i, o, e, t| o.each_line do |l| yield(l, i, o, e, t) end end end |
#handle_response(stderr, thread) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/rtasklib/execute.rb', line 46 def handle_response stderr, thread unless thread.value.success? puts stderr.read exit(-1) end end |
#popen3(program = 'task', *opts, &block) ⇒ Object
popen versions
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rtasklib/execute.rb', line 17 def popen3 program='task', *opts, &block execute = opts.unshift(program) execute = execute.join(" ") p execute Open3.popen3(execute) do |i, o, e, t| handle_response(e, t) yield(i, o, e, t) if block_given? end end |
#task_each_popen3(*opts, &block) ⇒ Object
40 41 42 43 44 |
# File 'lib/rtasklib/execute.rb', line 40 def task_each_popen3 *opts, &block popen3(program, *opts) do |i, o, e, t| yield(i, o, e, t) end end |
#task_popen3(*opts, &block) ⇒ Object
28 29 30 |
# File 'lib/rtasklib/execute.rb', line 28 def task_popen3 *opts, &block popen3('task', opts, &block) end |