feat: update meta plugin constructors to accept options and outputs
Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -16,16 +16,48 @@ pub struct MagicFileMetaPlugin {
|
||||
}
|
||||
|
||||
impl MagicFileMetaPlugin {
|
||||
pub fn new() -> MagicFileMetaPlugin {
|
||||
pub fn new(
|
||||
options: Option<std::collections::HashMap<String, serde_yaml::Value>>,
|
||||
outputs: Option<std::collections::HashMap<String, serde_yaml::Value>>,
|
||||
) -> MagicFileMetaPlugin {
|
||||
// Start with default options
|
||||
let mut final_options = Self::default_options();
|
||||
if let Some(opts) = options {
|
||||
for (key, value) in opts {
|
||||
final_options.insert(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
// Start with default outputs
|
||||
let mut final_outputs = std::collections::HashMap::new();
|
||||
let default_outputs = Self::default_outputs();
|
||||
for output_name in default_outputs {
|
||||
final_outputs.insert(output_name.clone(), serde_yaml::Value::String(output_name));
|
||||
}
|
||||
if let Some(outs) = outputs {
|
||||
for (key, value) in outs {
|
||||
final_outputs.insert(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
let max_buffer_size = final_options.get("max_buffer_size")
|
||||
.and_then(|v| v.as_u64())
|
||||
.unwrap_or(4096) as usize;
|
||||
|
||||
MagicFileMetaPlugin {
|
||||
buffer: Vec::new(),
|
||||
max_buffer_size: 4096, // Same as BinaryMetaPlugin
|
||||
max_buffer_size,
|
||||
is_saved: false,
|
||||
item_id: None,
|
||||
cookie: None,
|
||||
outputs: std::collections::HashMap::new(),
|
||||
outputs: final_outputs,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_simple() -> MagicFileMetaPlugin {
|
||||
Self::new(None, None)
|
||||
}
|
||||
}
|
||||
|
||||
fn get_magic_result(&self, flags: CookieFlags) -> io::Result<String> {
|
||||
// Use the existing cookie and just change flags
|
||||
|
||||
Reference in New Issue
Block a user