Module plugin

Module plugin 

Source
Expand description

Plugin system for IPFRS CLI

This module provides a plugin system that allows users to extend the IPFRS CLI with custom commands. Plugins can be written in any language and interfaced via a simple executable-based protocol.

§Plugin Discovery

Plugins are discovered in the following locations (in order):

  1. ~/.ipfrs/plugins/ - User plugins
  2. /usr/local/lib/ipfrs/plugins/ - System-wide plugins (Unix)
  3. $IPFRS_PLUGIN_PATH - Custom plugin directories (colon-separated)

§Plugin Protocol

Plugins are executables that follow this naming convention:

  • ipfrs-plugin-<name> for the executable

When invoked, plugins receive:

  • Arguments passed after the plugin name
  • Environment variables:
    • IPFRS_API_URL - Daemon API endpoint
    • IPFRS_DATA_DIR - Repository data directory
    • IPFRS_CONFIG - Config file path

§Examples

use ipfrs_cli::plugin::PluginManager;

// Discover all available plugins
let mut manager = PluginManager::new();
let plugins = manager.discover_plugins();

for plugin in plugins {
    println!("Found plugin: {}", plugin.name());
}

§Creating a Plugin

Create an executable named ipfrs-plugin-hello:

#!/bin/bash
# ipfrs-plugin-hello
echo "Hello from plugin!"
echo "API URL: $IPFRS_API_URL"

Make it executable and place in ~/.ipfrs/plugins/:

chmod +x ipfrs-plugin-hello
mv ipfrs-plugin-hello ~/.ipfrs/plugins/

Then use it:

ipfrs plugin hello

Structs§

Plugin
Represents a single plugin
PluginManager
Plugin manager for discovering and executing plugins