Class: LLM::Shell::Command::DisableTool

Inherits:
LLM::Shell::Command show all
Defined in:
lib/llm/shell/commands/disable_tool.rb

Constant Summary collapse

Error =
Class.new(RuntimeError)

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LLM::Shell::Command

builtin?, description, enabled?, inherited, #initialize, name

Constructor Details

This class inherits a constructor from LLM::Shell::Command

Class Method Details

.complete(name) ⇒ Array<String>

Completes a tool name.

Parameters:

  • name (String)

    The tool name to complete.

Returns:

  • (Array<String>)

    Returns the completed tool name(s)



16
17
18
# File 'lib/llm/shell/commands/disable_tool.rb', line 16

def self.complete(name)
  LLM::Shell.tools.map(&:name).select { _1.start_with?(name) }
end

Instance Method Details

#call(name) ⇒ void

This method returns an undefined value.

Disables the given tool.



23
24
25
26
27
28
29
30
31
# File 'lib/llm/shell/commands/disable_tool.rb', line 23

def call(name)
  tool = LLM::Shell.tools.find { _1.name == name }
  if tool
    tool.disable!
    io.rewind.print("tool disabled").end
  else
    raise Error, "unknown tool: #{name}"
  end
end