Module: BranchIOCLI::Helper::Methods
- Defined in:
- lib/branch_io_cli/helper/methods.rb
Instance Method Summary collapse
-
#sh(command, output = STDOUT) ⇒ Object
Execute a shell command with reporting.
Instance Method Details
#sh(command, output = STDOUT) ⇒ Object
Execute a shell command with reporting. The command itself is logged, then output from both stdout and stderr, then a success or failure message. Raises CommandError on error.
If output is STDOUT (the default), no redirection occurs. In all other cases, both stdout and stderr are redirected to output. In these cases, formatting (colors, highlights) may be lost.
:command: [String] A shell command to execute :output: [IO] An optional IO object to receive stdout and stderr from the command
17 18 19 20 |
# File 'lib/branch_io_cli/helper/methods.rb', line 17 def sh(command, output = STDOUT) status = output.log_command command raise CommandError, %{Error executing "#{command}": #{status}.} unless status.success? end |