Skip to content
Kward Search API index

Class: Kward::Tools::PrepareShellCommand

Inherits:
Base
  • Object
show all
Defined in:
lib/kward/tools/prepare_shell_command.rb

Overview

Prepares a command in the active embedded shell without executing it.

Instance Attribute Summary

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#schema

Constructor Details

#initialize(shell_prompt_session:) ⇒ PrepareShellCommand

Returns a new instance of PrepareShellCommand.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/kward/tools/prepare_shell_command.rb', line 10

def initialize(shell_prompt_session:)
  @shell_prompt_session = shell_prompt_session
  super(
    "prepare_shell_command",
    "Place a command in the active shell prompt without executing it. The user must press Enter to run it.",
    properties: {
      command: { type: "string", description: "Complete shell command to place in the prompt." }
    },
    required: ["command"]
  )
end

Instance Method Details

#call(args, _conversation, cancellation: nil) ⇒ Object



22
23
24
25
# File 'lib/kward/tools/prepare_shell_command.rb', line 22

def call(args, _conversation, cancellation: nil)
  cancellation&.raise_if_cancelled!
  @shell_prompt_session.prepare(argument(args, :command, ""))
end