Class: Aidp::ShellExecutor::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/aidp/shell_executor.rb

Overview

Immutable result of a shell-free command execution

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stdout:, stderr:, exit_status:) ⇒ Result

Returns a new instance of Result.

Parameters:

  • stdout (String) —

    standard output from the command

  • stderr (String) —

    standard error from the command

  • exit_status (Integer) —

    exit status code



36
37
38
39
40
41
# File 'lib/aidp/shell_executor.rb', line 36

def initialize(stdout:, stderr:, exit_status:)
  @stdout = stdout.to_s.freeze
  @stderr = stderr.to_s.freeze
  @exit_status = exit_status || 1
  freeze
end

Instance Attribute Details

#exit_status ⇒ Object (readonly)

Returns the value of attribute exit_status.



31
32
33
# File 'lib/aidp/shell_executor.rb', line 31

def exit_status
  @exit_status
end

#stderr ⇒ Object (readonly)

Returns the value of attribute stderr.



31
32
33
# File 'lib/aidp/shell_executor.rb', line 31

def stderr
  @stderr
end

#stdout ⇒ Object (readonly)

Returns the value of attribute stdout.



31
32
33
# File 'lib/aidp/shell_executor.rb', line 31

def stdout
  @stdout
end

Instance Method Details

#output ⇒ String

Combined output, equivalent to shell 2>&1 redirection

Returns:

  • (String)


50
51
52
# File 'lib/aidp/shell_executor.rb', line 50

def output
  [@stdout, @stderr].reject(&:empty?).join("\n")
end

#success? ⇒ Boolean

Returns true if exit_status is 0.

Returns:

  • (Boolean) —

    true if exit_status is 0



44
45
46
# File 'lib/aidp/shell_executor.rb', line 44

def success?
  @exit_status.zero?
end