Class: Ukiryu::Models::SuccessResponse

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/ukiryu/models/success_response.rb

Overview

Successful CLI execution response

Contains the complete result of a successful command execution structured into three phases: Request, Command, and Output. Optionally includes ExecutionReport with metrics when enabled.

Class Method Summary collapse

Class Method Details

.from_result(result, params = {}, command_definition = nil, execution_report: nil) ⇒ SuccessResponse

Create a SuccessResponse from an Executor::Result

Parameters:

  • result (Executor::Result)

    the execution result

  • params (Hash) (defaults to: {})

    the original parameters passed to the command

  • command_definition (CommandDefinition) (defaults to: nil)

    the command definition for context

  • execution_report (ExecutionReport, nil) (defaults to: nil)

    optional execution report with metrics

Returns:



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/ukiryu/models/success_response.rb', line 36

def self.from_result(result, params = {}, command_definition = nil, execution_report: nil)
  request = Arguments.from_params(params, command_definition)

  response = new(
    status: 'success',
    exit_code: result.status,
    request: request,
    command: CommandInfo.new(
      executable: result.executable,
      arguments: request, # Use the same structured arguments for the command
      full_command: result.command_info.full_command,
      shell: result.command_info.shell.to_s
    ),
    output: OutputInfo.new(
      stdout: result.stdout,
      stderr: result.error_output
    ),
    metadata: ExecutionMetadata.new(
      started_at: result.started_at.iso8601,
      finished_at: result.finished_at.iso8601,
      duration_seconds: result.duration,
      formatted_duration: result..formatted_duration
    )
  )

  # Add execution report if provided
  response.execution_report = execution_report if execution_report

  response
end