refactor: update meta plugin to use output mappings
Co-authored-by: aider (openai/andrew/openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
@@ -17,6 +17,7 @@ pub struct MetaPluginProgram {
|
||||
writer: Option<Box<dyn Write>>,
|
||||
item_id: Option<i64>,
|
||||
result: Option<String>,
|
||||
outputs: std::collections::HashMap<String, serde_yaml::Value>,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for MetaPluginProgram {
|
||||
@@ -29,6 +30,7 @@ impl std::fmt::Debug for MetaPluginProgram {
|
||||
.field("split_whitespace", &self.split_whitespace)
|
||||
.field("process", &self.process)
|
||||
.field("writer", &"Box<dyn Write>")
|
||||
.field("outputs", &self.outputs)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
@@ -48,6 +50,7 @@ impl MetaPluginProgram {
|
||||
writer: None,
|
||||
item_id: None,
|
||||
result: None,
|
||||
outputs: std::collections::HashMap::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,12 +118,7 @@ impl MetaPlugin for MetaPluginProgram {
|
||||
|
||||
// Save the result to database if we have item_id
|
||||
if let Some(item_id) = self.item_id {
|
||||
let meta = crate::db::Meta {
|
||||
id: item_id,
|
||||
name: self.meta_name.clone(),
|
||||
value: self.result.clone().unwrap(),
|
||||
};
|
||||
let _ = crate::db::store_meta(conn, meta);
|
||||
let _ = self.save_meta(conn, item_id, &self.meta_name.clone(), self.result.clone().unwrap());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -153,4 +151,25 @@ impl MetaPlugin for MetaPluginProgram {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn configure(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
|
||||
if let Some(outputs) = options.get("outputs") {
|
||||
if let Some(outputs_map) = outputs.as_mapping() {
|
||||
for (key, value) in outputs_map {
|
||||
if let Some(key_str) = key.as_str() {
|
||||
self.outputs.insert(key_str.to_string(), value.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
&self.outputs
|
||||
}
|
||||
|
||||
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
|
||||
self.outputs = outputs;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user