Module: Aidp::Interfaces::CommandExecutorInterface

Included in:
NullExecutor, TtyCommandExecutor
Defined in:
lib/aidp/interfaces/command_executor_interface.rb

Overview

CommandExecutorInterface defines the contract for executing shell commands. This interface allows for dependency injection of different command execution backends, facilitating extraction of provider code into standalone gems.

Examples:

Implementing the interface

class MyExecutor
  include Aidp::Interfaces::CommandExecutorInterface

  def execute(command, args: [], input: nil, timeout: nil, **options)
    # Implementation here
    CommandResult.new(stdout: "output", stderr: "", exit_status: 0)
  end
end

Using an injected executor

class Provider
  def initialize(executor: Aidp::Interfaces::TtyCommandExecutor.new)
    @executor = executor
  end

  def run_cli(command, args)
    @executor.execute(command, args: args, timeout: 30)
  end
end

Instance Method Summary collapse

Instance Method Details

#execute(command, args: [], input: nil, timeout: nil, **options) ⇒ CommandResult

Execute a shell command.

Parameters:

  • command (String)

    the command to execute (e.g., "claude", "cursor-agent")

  • args (Array<String>) (defaults to: [])

    command-line arguments

  • input (String, nil) (defaults to: nil)

    input to pass to stdin (or file path to read from)

  • timeout (Integer, nil) (defaults to: nil)

    timeout in seconds

  • options (Hash)

    additional options (env vars, working directory, etc.)

Returns:

Raises:



41
42
43
# File 'lib/aidp/interfaces/command_executor_interface.rb', line 41

def execute(command, args: [], input: nil, timeout: nil, **options)
  raise NotImplementedError, "#{self.class} must implement #execute"
end