refactor: use BaseMetaPlugin in ShellPidMetaPlugin
Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) <aider@aider.chat>
This commit is contained in:
@@ -1,43 +1,27 @@
|
||||
use std::env;
|
||||
use std::process;
|
||||
use crate::meta_plugin::{MetaPlugin, MetaPluginType};
|
||||
use crate::meta_plugin::{MetaPlugin, MetaPluginType, BaseMetaPlugin};
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct ShellPidMetaPlugin {
|
||||
is_finalized: bool,
|
||||
outputs: std::collections::HashMap<String, serde_yaml::Value>,
|
||||
options: std::collections::HashMap<String, serde_yaml::Value>,
|
||||
base: BaseMetaPlugin,
|
||||
}
|
||||
|
||||
impl ShellPidMetaPlugin {
|
||||
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>>,
|
||||
) -> ShellPidMetaPlugin {
|
||||
// Start with default options
|
||||
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
|
||||
let mut final_outputs = std::collections::HashMap::new();
|
||||
let default_outputs = Self::default().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 mut base = BaseMetaPlugin::new();
|
||||
|
||||
// Set default outputs
|
||||
let default_outputs = &["shell_pid"];
|
||||
base.initialize_plugin(default_outputs, options, outputs);
|
||||
|
||||
ShellPidMetaPlugin {
|
||||
is_finalized: false,
|
||||
outputs: final_outputs,
|
||||
options: final_options,
|
||||
base,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +92,7 @@ impl MetaPlugin for ShellPidMetaPlugin {
|
||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||
"shell_pid",
|
||||
serde_yaml::Value::String(pid),
|
||||
&self.outputs
|
||||
self.base.outputs()
|
||||
) {
|
||||
metadata.push(meta_data);
|
||||
}
|
||||
@@ -123,21 +107,21 @@ impl MetaPlugin for ShellPidMetaPlugin {
|
||||
}
|
||||
|
||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
&self.outputs
|
||||
self.base.outputs()
|
||||
}
|
||||
|
||||
fn outputs_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
||||
&mut self.outputs
|
||||
self.base.outputs_mut()
|
||||
}
|
||||
|
||||
|
||||
|
||||
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
&self.options
|
||||
self.base.options()
|
||||
}
|
||||
|
||||
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
||||
&mut self.options
|
||||
self.base.options_mut()
|
||||
}
|
||||
}
|
||||
use crate::meta_plugin::register_meta_plugin;
|
||||
|
||||
Reference in New Issue
Block a user