Class: Kward::PluginRegistry::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/kward/plugin_registry.rb

Overview

DSL object yielded by Kward.plugin blocks.

Instance Method Summary collapse

Constructor Details

#initialize(registry, path) ⇒ DSL

Returns a new instance of DSL.



92
93
94
95
# File 'lib/kward/plugin_registry.rb', line 92

def initialize(registry, path)
  @registry = registry
  @path = path
end

Instance Method Details

#command(name, description: "", argument_hint: "") {|args, ctx| ... } ⇒ Object

Registers a slash command.

Parameters:

  • name (String, #to_s)

    command name without the leading slash

  • description (String) (defaults to: "")

    short text shown in command listings

  • argument_hint (String) (defaults to: "")

    optional usage hint for arguments

Yield Parameters:

  • args (String)

    text after the command name

  • ctx (Context)

    plugin execution context



104
105
106
# File 'lib/kward/plugin_registry.rb', line 104

def command(name, description: "", argument_hint: "", &block)
  @registry.register_command(name, description: description, argument_hint: argument_hint, path: @path, &block)
end

Registers or replaces the custom footer renderer.

Yield Parameters:

  • ctx (Context)

    plugin execution context



111
112
113
# File 'lib/kward/plugin_registry.rb', line 111

def footer(&block)
  @registry.register_footer(path: @path, &block)
end

#on_transcript_event {|event, ctx| ... } ⇒ Object

Registers a live transcript event observer.

Yield Parameters:



119
120
121
# File 'lib/kward/plugin_registry.rb', line 119

def on_transcript_event(&block)
  @registry.register_transcript_event(path: @path, &block)
end

#prompt_context {|ctx| ... } ⇒ Object

Registers prompt context text injected into future system prompts.

Yield Parameters:

  • ctx (Context)

    plugin execution context



126
127
128
# File 'lib/kward/plugin_registry.rb', line 126

def prompt_context(&block)
  @registry.register_prompt_context(path: @path, &block)
end