Raxol.Core.Runtime.Plugins.CommandHelper (Raxol v0.4.0)

View Source

Handles plugin command registration and dispatch for the Plugin Manager.

Summary

Functions

Finds the plugin responsible for handling a command.

Finds the plugin ID for a given module.

Handles the dispatching of a command to the appropriate plugin.

Registers the commands exposed by a plugin.

Unregisters all commands associated with a specific plugin module.

Validates command arguments.

Functions

find_plugin_for_command(command_table, command_name, namespace, arity)

Finds the plugin responsible for handling a command.

Uses the CommandRegistry to look up the command by name and optional namespace. Returns {:ok, module, function, arity} | :not_found.

find_plugin_id_by_module(plugins, module)

Finds the plugin ID for a given module.

handle_command(command_table, command_name_str, namespace, args, state)

Handles the dispatching of a command to the appropriate plugin.

This function is called by the Manager's handle_cast. It finds the plugin, calls its command handler, and returns an updated plugin state map or an error indicator.

Returns {:ok, updated_plugin_states_map} | :not_found | {:error, reason}.

register_plugin_commands(plugin_module, plugin_state, command_table)

Registers the commands exposed by a plugin.

Calls the plugin's get_commands/1 or get_commands/0 callback and registers them in the command table.

unregister_plugin_commands(command_table, plugin_module)

Unregisters all commands associated with a specific plugin module.

validate_command_args(args)

Validates command arguments.