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::env;
|
||||||
use std::process;
|
use std::process;
|
||||||
use crate::meta_plugin::{MetaPlugin, MetaPluginType};
|
use crate::meta_plugin::{MetaPlugin, MetaPluginType, BaseMetaPlugin};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub struct ShellPidMetaPlugin {
|
pub struct ShellPidMetaPlugin {
|
||||||
is_finalized: bool,
|
is_finalized: bool,
|
||||||
outputs: std::collections::HashMap<String, serde_yaml::Value>,
|
base: BaseMetaPlugin,
|
||||||
options: std::collections::HashMap<String, serde_yaml::Value>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ShellPidMetaPlugin {
|
impl ShellPidMetaPlugin {
|
||||||
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>>,
|
||||||
) -> ShellPidMetaPlugin {
|
) -> ShellPidMetaPlugin {
|
||||||
// Start with default options
|
let mut base = 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 = &["shell_pid"];
|
||||||
let default_outputs = Self::default().default_outputs();
|
base.initialize_plugin(default_outputs, options, 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ShellPidMetaPlugin {
|
ShellPidMetaPlugin {
|
||||||
is_finalized: false,
|
is_finalized: false,
|
||||||
outputs: final_outputs,
|
base,
|
||||||
options: final_options,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +92,7 @@ impl MetaPlugin for ShellPidMetaPlugin {
|
|||||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||||
"shell_pid",
|
"shell_pid",
|
||||||
serde_yaml::Value::String(pid),
|
serde_yaml::Value::String(pid),
|
||||||
&self.outputs
|
self.base.outputs()
|
||||||
) {
|
) {
|
||||||
metadata.push(meta_data);
|
metadata.push(meta_data);
|
||||||
}
|
}
|
||||||
@@ -123,21 +107,21 @@ impl MetaPlugin for ShellPidMetaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
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> {
|
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> {
|
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> {
|
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;
|
use crate::meta_plugin::register_meta_plugin;
|
||||||
|
|||||||
Reference in New Issue
Block a user