Class: Rubino::Commands::Command
- Inherits:
-
Object
- Object
- Rubino::Commands::Command
- Defined in:
- lib/rubino/commands/command.rb
Overview
Represents a custom slash command loaded from a Markdown file. Supports $ARGUMENTS, $1-$9 positional params, @file refs.
Shell injection via !‘command` is opt-in and disabled by default. Enable it by setting commands.shell_injection_enabled: true in your configuration — only do so in trusted, controlled environments.
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path:) ⇒ Command
constructor
A new instance of Command.
-
#render(arguments = "") ⇒ Object
Renders the command prompt with given arguments.
-
#template ⇒ Object
Returns the raw template content.
Constructor Details
#initialize(path:) ⇒ Command
Returns a new instance of Command.
16 17 18 19 20 21 |
# File 'lib/rubino/commands/command.rb', line 16 def initialize(path:) @path = path @metadata = {} @template = nil parse! end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
14 15 16 |
# File 'lib/rubino/commands/command.rb', line 14 def agent @agent end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
14 15 16 |
# File 'lib/rubino/commands/command.rb', line 14 def description @description end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
14 15 16 |
# File 'lib/rubino/commands/command.rb', line 14 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/rubino/commands/command.rb', line 14 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
14 15 16 |
# File 'lib/rubino/commands/command.rb', line 14 def path @path end |
Instance Method Details
#render(arguments = "") ⇒ Object
Renders the command prompt with given arguments.
24 25 26 27 28 29 30 31 32 |
# File 'lib/rubino/commands/command.rb', line 24 def render(arguments = "") prompt = template.dup substitute_arguments!(prompt, arguments) process_shell_injections!(prompt) process_file_references!(prompt) prompt.strip end |
#template ⇒ Object
Returns the raw template content.
35 36 37 |
# File 'lib/rubino/commands/command.rb', line 35 def template @template ||= load_template end |