Module: LLM::Shell::Command::Extension

Included in:
LLM
Defined in:
lib/llm/shell/command/extension.rb

Overview

The LLM::Shell::Command::Extension module extends the LLM constant with methods that can provide shell commands for an active llm-shell session.

Examples:

hello command

LLM.command(:hello) do |cmd|
  cmd.define do |name|
    io.rewind.print("Hello #{name}")
  end
end

Instance Method Summary collapse

Instance Method Details

#command(name) {|cmd| ... } ⇒ void

This method returns an undefined value.

Examples:

LLM.command(:hello) do |cmd|
  cmd.define do |name|
    io.rewind.print("Hello #{name}")
  end
end

Parameters:

  • name (String)

    The name of the command

Yield Parameters:



28
29
30
31
32
33
# File 'lib/llm/shell/command/extension.rb', line 28

def command(name)
  cmd = LLM::Shell::Command.new
  cmd.name(name)
  yield cmd
  commands[cmd.name] = cmd
end

#commandsHash<String, LLM::Shell::Command>

Returns:



37
38
39
# File 'lib/llm/shell/command/extension.rb', line 37

def commands
  @commands ||= {}
end