Ugh
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use std::env;
|
||||
use crate::meta_plugin::{MetaPlugin, MetaPluginType};
|
||||
use std::env;
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct CwdMetaPlugin {
|
||||
@@ -13,13 +13,14 @@ impl CwdMetaPlugin {
|
||||
outputs: Option<std::collections::HashMap<String, serde_yaml::Value>>,
|
||||
) -> CwdMetaPlugin {
|
||||
let mut base = crate::meta_plugin::BaseMetaPlugin::new();
|
||||
|
||||
|
||||
// Set default outputs
|
||||
let default_outputs = vec!["cwd".to_string()];
|
||||
for output_name in default_outputs {
|
||||
base.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 {
|
||||
@@ -31,24 +32,23 @@ impl CwdMetaPlugin {
|
||||
base.outputs.insert(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CwdMetaPlugin {
|
||||
is_finalized: false,
|
||||
base,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl MetaPlugin for CwdMetaPlugin {
|
||||
fn is_finalized(&self) -> bool {
|
||||
self.is_finalized
|
||||
}
|
||||
|
||||
|
||||
fn set_finalized(&mut self, finalized: bool) {
|
||||
self.is_finalized = finalized;
|
||||
}
|
||||
|
||||
|
||||
fn finalize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
// If already finalized, don't process again
|
||||
if self.is_finalized {
|
||||
@@ -57,10 +57,10 @@ impl MetaPlugin for CwdMetaPlugin {
|
||||
is_finalized: true,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Mark as finalized
|
||||
self.is_finalized = true;
|
||||
|
||||
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata: Vec::new(),
|
||||
is_finalized: true,
|
||||
@@ -70,7 +70,7 @@ impl MetaPlugin for CwdMetaPlugin {
|
||||
fn meta_type(&self) -> MetaPluginType {
|
||||
MetaPluginType::Cwd
|
||||
}
|
||||
|
||||
|
||||
fn initialize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
// If already finalized, don't process again
|
||||
if self.is_finalized {
|
||||
@@ -79,42 +79,40 @@ impl MetaPlugin for CwdMetaPlugin {
|
||||
is_finalized: true,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
let mut metadata = Vec::new();
|
||||
let cwd = match env::current_dir() {
|
||||
Ok(path) => path.to_string_lossy().to_string(),
|
||||
Err(_) => "unknown".to_string(),
|
||||
};
|
||||
|
||||
|
||||
// Use process_metadata_outputs to handle output mapping
|
||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||
"cwd",
|
||||
serde_yaml::Value::String(cwd),
|
||||
self.base.outputs()
|
||||
"cwd",
|
||||
serde_yaml::Value::String(cwd),
|
||||
self.base.outputs(),
|
||||
) {
|
||||
metadata.push(meta_data);
|
||||
}
|
||||
|
||||
|
||||
crate::meta_plugin::MetaPluginResponse {
|
||||
metadata,
|
||||
is_finalized: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
self.base.outputs()
|
||||
}
|
||||
|
||||
|
||||
fn outputs_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
||||
self.base.outputs_mut()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
self.base.options()
|
||||
}
|
||||
|
||||
|
||||
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
|
||||
self.base.options_mut()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user