Class: Kward::Tools::RunShellCommand

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

Instance Attribute Summary

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#schema

Constructor Details

#initialize(workspace:) ⇒ RunShellCommand

Returns a new instance of RunShellCommand.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/kward/tools/run_shell_command.rb', line 7

def initialize(workspace:)
  @workspace = workspace
  super(
    "run_shell_command",
    "Run a shell command from the workspace root.",
    properties: {
      command: { type: "string", description: "Command to run." },
      timeout_seconds: { type: "integer", description: "Timeout seconds; default 30." }
    },
    required: ["command"]
  )
end

Instance Method Details

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



20
21
22
23
24
25
# File 'lib/kward/tools/run_shell_command.rb', line 20

def call(args, _conversation, cancellation: nil)
  command = argument(args, :command, "")
  timeout_seconds = argument(args, :timeout_seconds, Workspace::DEFAULT_COMMAND_TIMEOUT_SECONDS)

  @workspace.run_shell_command(command, timeout_seconds: timeout_seconds, cancellation: cancellation)
end