Class: LLM::Shell::Command
- Inherits:
-
Object
- Object
- LLM::Shell::Command
- Defined in:
- lib/llm/shell/commands/help.rb,
lib/llm/shell/commands/utils.rb,
lib/llm/shell/command/extension.rb,
lib/llm/shell/commands/show_chat.rb,
lib/llm/shell/commands/dir_import.rb,
lib/llm/shell/commands/file_import.rb,
lib/llm/shell/commands/clear_screen.rb,
lib/llm/shell/commands/show_version.rb,
lib/llm/shell/commands/system_prompt.rb,
lib/llm/shell/command.rb
Defined Under Namespace
Modules: Extension, Utils Classes: ClearScreen, Context, DirImport, FileImport, Help, ShowChat, ShowVersion, SystemPrompt
Instance Attribute Summary collapse
-
#object ⇒ Class, #call
readonly
Returns the underlying command object.
Instance Method Summary collapse
-
#builtin! ⇒ void
Mark this command as builtin command.
-
#builtin? ⇒ Boolean
Returns true if this is a builtin command.
-
#call(*argv) ⇒ Object
Call the command.
-
#define(klass = nil, &b) ⇒ void
(also: #register)
Define the command.
-
#description(desc = nil) ⇒ String
Set or get the command description.
-
#name(name = nil) ⇒ String
Set or get the command name.
-
#setup(bot, io) ⇒ void
Setup the command context.
Instance Attribute Details
#object ⇒ Class, #call (readonly)
Returns the underlying command object
18 19 20 |
# File 'lib/llm/shell/command.rb', line 18 def object @object end |
Instance Method Details
#builtin! ⇒ void
This method returns an undefined value.
Mark this command as builtin command
84 85 86 |
# File 'lib/llm/shell/command.rb', line 84 def builtin! @builtin = true end |
#builtin? ⇒ Boolean
Returns true if this is a builtin command
77 78 79 |
# File 'lib/llm/shell/command.rb', line 77 def builtin? @builtin end |
#call(*argv) ⇒ Object
Call the command
64 65 66 67 68 69 70 71 72 |
# File 'lib/llm/shell/command.rb', line 64 def call(*argv) if @context.nil? raise "context has not been setup" elsif Class === @object @object.new(@context).call(*argv) else @context.instance_exec(*argv, &@object) end end |
#define(klass = nil, &b) ⇒ void Also known as: register
This method returns an undefined value.
Define the command
56 57 58 |
# File 'lib/llm/shell/command.rb', line 56 def define(klass = nil, &b) @object = klass || b end |
#description(desc = nil) ⇒ String
Set or get the command description
38 39 40 41 42 43 44 |
# File 'lib/llm/shell/command.rb', line 38 def description(desc = nil) if desc @description = desc else @description end end |
#name(name = nil) ⇒ String
Set or get the command name
25 26 27 28 29 30 31 |
# File 'lib/llm/shell/command.rb', line 25 def name(name = nil) if name @name = name else @name end end |
#setup(bot, io) ⇒ void
This method returns an undefined value.
Setup the command context
49 50 51 |
# File 'lib/llm/shell/command.rb', line 49 def setup(bot, io) @context = Context.new(bot, io) end |