Class: Cuprum::Cli::Dependencies::SystemCommand
- Inherits:
-
Object
- Object
- Cuprum::Cli::Dependencies::SystemCommand
- Defined in:
- lib/cuprum/cli/dependencies/system_command.rb
Overview
Utility wrapper for running system command and capturing output.
Direct Known Subclasses
Defined Under Namespace
Classes: CapturedOutput, Mock
Instance Method Summary collapse
-
#capture(command, .arguments: [], environment: {}, options: {}) ⇒ Cuprum::Result<Cuprum::Cli::Dependencies::SystemCommand::CapturedOutput>
Executes the system command and returns the captured output.
-
#spawn(command, arguments: [], enviroment:, options: {}) ⇒ Cuprum::Result<nil>
Spawns a process to run the system command.
Instance Method Details
#capture(command, .arguments: [], environment: {}, options: {}) ⇒ Cuprum::Result<Cuprum::Cli::Dependencies::SystemCommand::CapturedOutput>
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/cuprum/cli/dependencies/system_command.rb', line 35 def capture(command, **) value = capture_command(command, **) return Cuprum::Result.new(value:) if value.success? error = Cuprum::Cli::Errors::SystemCommandFailure.new( command:, details: value.error, exit_status: value.status.exitstatus ) Cuprum::Result.new(error:, value:) end |
#spawn(command, arguments: [], enviroment:, options: {}) ⇒ Cuprum::Result<nil>
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/cuprum/cli/dependencies/system_command.rb', line 63 def spawn(command, **) status = spawn_command(command, **) return Cuprum::Result.new if status.success? error = Cuprum::Cli::Errors::SystemCommandFailure.new( command:, exit_status: status.exitstatus ) Cuprum::Result.new(error:) end |