Class: LLM::Shell::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/llm/shell/command.rb

Defined Under Namespace

Classes: ClearScreen, DebugMode, DirImport, DisableTool, EnableTool, FileImport, Help, ShowChat, ShowVersion, SystemPrompt

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bot, io) ⇒ Command

Returns a new instance of Command.

Parameters:



59
60
61
62
# File 'lib/llm/shell/command.rb', line 59

def initialize(bot, io)
  @bot = bot
  @io = io
end

Class Method Details

.builtin?Boolean

Returns true for builtin commands

Returns:

  • (Boolean)


8
9
10
11
# File 'lib/llm/shell/command.rb', line 8

def self.builtin?
  path, _ = instance_method(:call).source_location
  path&.include?(LLM::Shell.root)
end

.description(desc = nil) ⇒ String

Set or get the command description

Parameters:

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

    The description of the command

Returns:

  • (String)


46
47
48
49
50
51
52
# File 'lib/llm/shell/command.rb', line 46

def self.description(desc = nil)
  if desc
    @description = desc
  else
    @description
  end
end

.enabled?Boolean

Always returns true

Returns:

  • (Boolean)


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

def self.enabled?
  true
end

.inherited(klass) ⇒ void

This method returns an undefined value.

Parameters:

  • klass (Class)

    A subclass



24
25
26
# File 'lib/llm/shell/command.rb', line 24

def self.inherited(klass)
  LLM::Shell.commands << klass
end

.name(name = nil) ⇒ String

Set or get the command name

Parameters:

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

    The name of the command

Returns:

  • (String)


33
34
35
36
37
38
39
# File 'lib/llm/shell/command.rb', line 33

def self.name(name = nil)
  if name
    @name = name
  else
    @name
  end
end

Instance Method Details

#call(*argv) ⇒ Object

Call the command

Raises:

  • (NotImplementedError)


67
68
69
# File 'lib/llm/shell/command.rb', line 67

def call(*argv)
  raise NotImplementedError
end