feat: add default implementations for outputs and options methods
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -40,6 +40,22 @@ impl BaseMetaPlugin {
|
|||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||||
|
&self.outputs
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn outputs_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
||||||
|
&mut self.outputs
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||||
|
&self.options
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
||||||
|
&mut self.options
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MetaPlugin for BaseMetaPlugin {
|
impl MetaPlugin for BaseMetaPlugin {
|
||||||
|
|||||||
@@ -10,40 +10,38 @@ use std::collections::HashMap;
|
|||||||
pub struct CwdMetaPlugin {
|
pub struct CwdMetaPlugin {
|
||||||
meta_name: String,
|
meta_name: String,
|
||||||
is_saved: bool,
|
is_saved: bool,
|
||||||
outputs: std::collections::HashMap<String, serde_yaml::Value>,
|
base: crate::meta_plugin::BaseMetaPlugin,
|
||||||
options: std::collections::HashMap<String, serde_yaml::Value>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CwdMetaPlugin {
|
impl CwdMetaPlugin {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
_options: Option<std::collections::HashMap<String, serde_yaml::Value>>,
|
options: Option<std::collections::HashMap<String, serde_yaml::Value>>,
|
||||||
outputs: Option<std::collections::HashMap<String, serde_yaml::Value>>,
|
outputs: Option<std::collections::HashMap<String, serde_yaml::Value>>,
|
||||||
) -> CwdMetaPlugin {
|
) -> CwdMetaPlugin {
|
||||||
// Start with default options
|
let mut base = crate::meta_plugin::BaseMetaPlugin::new();
|
||||||
let mut final_options = std::collections::HashMap::new();
|
|
||||||
if let Some(opts) = _options {
|
|
||||||
for (key, value) in opts {
|
|
||||||
final_options.insert(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start with default outputs
|
// Set default outputs
|
||||||
let mut final_outputs = std::collections::HashMap::new();
|
|
||||||
let default_outputs = vec!["cwd".to_string()];
|
let default_outputs = vec!["cwd".to_string()];
|
||||||
for output_name in default_outputs {
|
for output_name in default_outputs {
|
||||||
final_outputs.insert(output_name.clone(), serde_yaml::Value::String(output_name));
|
base.outputs.insert(output_name.clone(), serde_yaml::Value::String(output_name));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply provided options and outputs
|
||||||
|
if let Some(opts) = options {
|
||||||
|
for (key, value) in opts {
|
||||||
|
base.options.insert(key, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if let Some(outs) = outputs {
|
if let Some(outs) = outputs {
|
||||||
for (key, value) in outs {
|
for (key, value) in outs {
|
||||||
final_outputs.insert(key, value);
|
base.outputs.insert(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CwdMetaPlugin {
|
CwdMetaPlugin {
|
||||||
meta_name: "cwd".to_string(),
|
meta_name: "cwd".to_string(),
|
||||||
is_saved: false,
|
is_saved: false,
|
||||||
outputs: final_outputs,
|
base,
|
||||||
options: final_options,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,25 +85,6 @@ impl MetaPlugin for CwdMetaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
|
||||||
&self.outputs
|
|
||||||
}
|
|
||||||
|
|
||||||
fn outputs_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
|
||||||
&mut self.outputs
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_outputs(&self) -> Vec<String> {
|
|
||||||
vec!["cwd".to_string()]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
|
||||||
&self.options
|
|
||||||
}
|
|
||||||
|
|
||||||
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
|
||||||
&mut self.options
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
|
|||||||
Reference in New Issue
Block a user