feat: Implement registry for meta plugins
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -225,3 +225,47 @@ impl MetaPlugin for MetaPluginExec {
|
||||
&mut self.options
|
||||
}
|
||||
}
|
||||
use crate::meta_plugin::register_meta_plugin;
|
||||
use crate::meta_plugin::MetaPluginType;
|
||||
|
||||
// Register the plugin at module initialization time
|
||||
#[ctor::ctor]
|
||||
fn register_exec_plugin() {
|
||||
register_meta_plugin(MetaPluginType::Exec, |options, outputs| {
|
||||
// For exec type, we need to parse the command from options
|
||||
let mut program_name = String::new();
|
||||
let mut args = Vec::new();
|
||||
let mut meta_name = MetaPluginType::Exec.to_string();
|
||||
let mut split_whitespace = true;
|
||||
|
||||
if let Some(opts) = &options {
|
||||
if let Some(command_value) = opts.get("command") {
|
||||
if let Some(command_str) = command_value.as_str() {
|
||||
let parts: Vec<&str> = command_str.split_whitespace().collect();
|
||||
if !parts.is_empty() {
|
||||
program_name = parts[0].to_string();
|
||||
args = parts[1..].iter().map(|s| s.to_string()).collect();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Handle other options if needed
|
||||
if let Some(split_value) = opts.get("split_whitespace") {
|
||||
if let Some(split_bool) = split_value.as_bool() {
|
||||
split_whitespace = split_bool;
|
||||
}
|
||||
}
|
||||
if let Some(name_value) = opts.get("name") {
|
||||
if let Some(name_str) = name_value.as_str() {
|
||||
meta_name = name_str.to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Box::new(MetaPluginExec::new(&program_name,
|
||||
args.iter().map(|s| s.as_str()).collect(),
|
||||
meta_name,
|
||||
split_whitespace,
|
||||
options,
|
||||
outputs))
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user