Class: LLM::Shell::Command
- Inherits:
-
Object
- Object
- LLM::Shell::Command
- Defined in:
- lib/llm/shell/command.rb
Direct Known Subclasses
ClearScreen, DebugMode, DirImport, DisableTool, EnableTool, FileImport, Help, ShowChat, ShowVersion, SystemPrompt
Defined Under Namespace
Classes: ClearScreen, DebugMode, DirImport, DisableTool, EnableTool, FileImport, Help, ShowChat, ShowVersion, SystemPrompt
Class Method Summary collapse
-
.builtin? ⇒ Boolean
Returns true for builtin commands.
-
.description(desc = nil) ⇒ String
Set or get the command description.
-
.enabled? ⇒ Boolean
Always returns true.
- .inherited(klass) ⇒ void
-
.name(name = nil) ⇒ String
Set or get the command name.
Instance Method Summary collapse
-
#call(*argv) ⇒ Object
Call the command.
-
#initialize(bot, io) ⇒ Command
constructor
A new instance of Command.
Constructor Details
#initialize(bot, io) ⇒ Command
Returns a new instance of Command.
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
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
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
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.
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
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
67 68 69 |
# File 'lib/llm/shell/command.rb', line 67 def call(*argv) raise NotImplementedError end |