Module: InvocaGems::ShellCommand
Defined Under Namespace
Classes: Response
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
4 5 6 |
# File 'lib/invoca_gems/shell_command.rb', line 4 def self.included(klass) klass.send(:extend, InvocaGems::ShellCommand) end |
Instance Method Details
#shell_command(command:, path: '.', presenter:, raise_errors: true) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/invoca_gems/shell_command.rb', line 11 def shell_command(command:, path: '.', presenter:, raise_errors: true) presenter.set_subtask "cd #{path}; #{command}" r = Response.new(*Open3.capture3("cd #{path}; #{command}")) if r.code && r.code.success? r.stdout.strip else if raise_errors presenter. "cd #{path}; #{command}: returned error #{r.code.exitstatus}: #{r.stdout}\n#{r.stderr}" end end end |