Class: SwarmCLI::CommandRegistry
- Inherits:
-
Object
- Object
- SwarmCLI::CommandRegistry
- Defined in:
- lib/swarm_cli/command_registry.rb
Overview
Registry for CLI command extensions
Allows gems (like swarm_memory) to register additional CLI commands that integrate seamlessly with the main swarm CLI.
Class Method Summary collapse
-
.commands ⇒ Array<String>
Get all registered command names.
-
.get(command_name) ⇒ Class?
Get command class by name.
-
.register(command_name, command_class) ⇒ void
Register a command extension.
-
.registered?(command_name) ⇒ Boolean
Check if a command is registered.
Class Method Details
.commands ⇒ Array<String>
Get all registered command names
55 56 57 58 |
# File 'lib/swarm_cli/command_registry.rb', line 55 def commands @extensions ||= {} @extensions.keys end |
.get(command_name) ⇒ Class?
Get command class by name
38 39 40 41 |
# File 'lib/swarm_cli/command_registry.rb', line 38 def get(command_name) @extensions ||= {} @extensions[command_name.to_s] end |
.register(command_name, command_class) ⇒ void
This method returns an undefined value.
Register a command extension
29 30 31 32 |
# File 'lib/swarm_cli/command_registry.rb', line 29 def register(command_name, command_class) @extensions ||= {} @extensions[command_name.to_s] = command_class end |
.registered?(command_name) ⇒ Boolean
Check if a command is registered
47 48 49 50 |
# File 'lib/swarm_cli/command_registry.rb', line 47 def registered?(command_name) @extensions ||= {} @extensions.key?(command_name.to_s) end |