refactor: remove initialize() call and use plugin outputs directly
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -161,31 +161,19 @@ impl MetaPlugin for DigestMetaPlugin {
|
|||||||
|
|
||||||
let mut metadata = Vec::new();
|
let mut metadata = Vec::new();
|
||||||
|
|
||||||
// Compute the selected hash
|
// Update outputs based on the selected hash method
|
||||||
if let Some(hasher) = &mut self.hasher {
|
if let Some(hasher) = &mut self.hasher {
|
||||||
let hash_value = hasher.finalize();
|
let hash_value = hasher.finalize();
|
||||||
let output_name = hasher.output_name();
|
let output_name = hasher.output_name();
|
||||||
|
|
||||||
// Add the selected hash output
|
// Set the selected hash output
|
||||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
self.outputs.insert(output_name.to_string(), serde_yaml::Value::String(hash_value));
|
||||||
output_name,
|
|
||||||
serde_yaml::Value::String(hash_value),
|
|
||||||
&self.outputs
|
|
||||||
) {
|
|
||||||
metadata.push(meta_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set all other digest outputs to None
|
// Set all other digest outputs to None
|
||||||
let all_outputs = vec!["digest_md5", "digest_sha256", "digest_sha512"];
|
let all_outputs = vec!["digest_md5", "digest_sha256", "digest_sha512"];
|
||||||
for output_name in all_outputs {
|
for output_name in all_outputs {
|
||||||
if output_name != hasher.output_name() {
|
if output_name != hasher.output_name() {
|
||||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
self.outputs.insert(output_name.to_string(), serde_yaml::Value::Null);
|
||||||
output_name,
|
|
||||||
serde_yaml::Value::Null,
|
|
||||||
&self.outputs
|
|
||||||
) {
|
|
||||||
metadata.push(meta_data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -234,47 +234,32 @@ impl MetaPlugin for HostnameMetaPlugin {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Always process all outputs, setting disabled ones to Null
|
// Update outputs based on enabled status
|
||||||
// Handle hostname output
|
// Handle hostname output
|
||||||
let hostname_output_value = if hostname_enabled {
|
if hostname_enabled {
|
||||||
serde_yaml::Value::String(hostname_value)
|
if let Some(output_value) = self.outputs.get_mut("hostname") {
|
||||||
|
*output_value = serde_yaml::Value::String(hostname_value);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
serde_yaml::Value::Null
|
self.outputs.insert("hostname".to_string(), serde_yaml::Value::Null);
|
||||||
};
|
|
||||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
|
||||||
"hostname",
|
|
||||||
hostname_output_value,
|
|
||||||
&self.outputs
|
|
||||||
) {
|
|
||||||
metadata.push(meta_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle hostname_full output
|
// Handle hostname_full output
|
||||||
let hostname_full_output_value = if hostname_full_enabled {
|
if hostname_full_enabled {
|
||||||
serde_yaml::Value::String(full_hostname.clone())
|
if let Some(output_value) = self.outputs.get_mut("hostname_full") {
|
||||||
|
*output_value = serde_yaml::Value::String(full_hostname.clone());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
serde_yaml::Value::Null
|
self.outputs.insert("hostname_full".to_string(), serde_yaml::Value::Null);
|
||||||
};
|
|
||||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
|
||||||
"hostname_full",
|
|
||||||
hostname_full_output_value,
|
|
||||||
&self.outputs
|
|
||||||
) {
|
|
||||||
metadata.push(meta_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle hostname_short output
|
// Handle hostname_short output
|
||||||
let hostname_short_output_value = if hostname_short_enabled {
|
if hostname_short_enabled {
|
||||||
serde_yaml::Value::String(short_hostname)
|
if let Some(output_value) = self.outputs.get_mut("hostname_short") {
|
||||||
|
*output_value = serde_yaml::Value::String(short_hostname);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
serde_yaml::Value::Null
|
self.outputs.insert("hostname_short".to_string(), serde_yaml::Value::Null);
|
||||||
};
|
|
||||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
|
||||||
"hostname_short",
|
|
||||||
hostname_short_output_value,
|
|
||||||
&self.outputs
|
|
||||||
) {
|
|
||||||
metadata.push(meta_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark as finalized since this plugin only needs to run once
|
// Mark as finalized since this plugin only needs to run once
|
||||||
|
|||||||
@@ -175,19 +175,13 @@ fn build_meta_plugins_configured_table(settings: &config::Settings) -> Option<Ta
|
|||||||
.map(|(k, v)| (k.clone(), serde_yaml::Value::String(v.clone())))
|
.map(|(k, v)| (k.clone(), serde_yaml::Value::String(v.clone())))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// Create the actual plugin with merged options
|
// Create the actual plugin with merged options - the constructor will handle setting up outputs
|
||||||
let mut actual_plugin = get_meta_plugin(
|
let actual_plugin = get_meta_plugin(
|
||||||
meta_plugin_type.clone(),
|
meta_plugin_type.clone(),
|
||||||
Some(effective_options.clone()),
|
Some(effective_options.clone()),
|
||||||
Some(outputs_converted),
|
Some(outputs_converted),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Clone the plugin to avoid modifying the original when we initialize it
|
|
||||||
let mut plugin_for_display = actual_plugin.clone();
|
|
||||||
// Initialize the plugin to process the options and generate the actual outputs
|
|
||||||
// This will set disabled outputs to None
|
|
||||||
let _ = plugin_for_display.initialize();
|
|
||||||
|
|
||||||
// Get the default plugin to see its default options
|
// Get the default plugin to see its default options
|
||||||
let default_plugin = get_meta_plugin(
|
let default_plugin = get_meta_plugin(
|
||||||
meta_plugin_type.clone(),
|
meta_plugin_type.clone(),
|
||||||
@@ -202,8 +196,7 @@ fn build_meta_plugins_configured_table(settings: &config::Settings) -> Option<Ta
|
|||||||
all_options.insert(key.clone(), value.clone());
|
all_options.insert(key.clone(), value.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert options to a YAML string, but first make sure to show the actual values used
|
// Convert options to a YAML string
|
||||||
// This includes any conversions we made (like "false" string to Bool(false))
|
|
||||||
let options_str = if all_options.is_empty() {
|
let options_str = if all_options.is_empty() {
|
||||||
"{}".to_string()
|
"{}".to_string()
|
||||||
} else {
|
} else {
|
||||||
@@ -213,10 +206,9 @@ fn build_meta_plugins_configured_table(settings: &config::Settings) -> Option<Ta
|
|||||||
.to_string()
|
.to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
// Show only non-null outputs from the plugin after initialization
|
// Show only non-null outputs from the plugin
|
||||||
// This reflects which outputs would actually be generated
|
|
||||||
let mut enabled_output_pairs = Vec::new();
|
let mut enabled_output_pairs = Vec::new();
|
||||||
for (key, value) in plugin_for_display.outputs() {
|
for (key, value) in actual_plugin.outputs() {
|
||||||
// Skip null values (disabled outputs)
|
// Skip null values (disabled outputs)
|
||||||
if value.is_null() {
|
if value.is_null() {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user