refactor: update empty hashmap initialization with lazy initialization

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-26 18:06:50 -03:00
parent 3fb436dc44
commit 1d463323ce
5 changed files with 13 additions and 8 deletions

View File

@@ -69,9 +69,10 @@ impl MetaPlugin for BinaryMetaPlugin {
}
}
let is_finalized = !metadata.is_empty();
MetaPluginResponse {
metadata,
is_finalized: !metadata.is_empty(),
is_finalized,
}
}
@@ -121,7 +122,7 @@ impl MetaPlugin for BinaryMetaPlugin {
self.base.options_mut()
}
fn configure_options(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
fn configure_options(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> anyhow::Result<()> {
if let Some(max_buffer_size) = options.get("max_buffer_size") {
if let Some(size) = max_buffer_size.as_u64() {
self.max_buffer_size = size as usize;

View File

@@ -182,7 +182,7 @@ impl MetaPlugin for MagicFileMetaPlugin {
"magic_file".to_string()
}
fn configure_options(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
fn configure_options(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> anyhow::Result<()> {
if let Some(max_buffer_size) = options.get("max_buffer_size") {
if let Some(size) = max_buffer_size.as_u64() {
self.max_buffer_size = size as usize;

View File

@@ -162,9 +162,10 @@ impl MetaPlugin for MetaPluginProgram {
self.result = Some(result);
// Create metadata to be returned
let result_clone = result.clone();
metadata.push(crate::meta_plugin::MetaData {
name: self.meta_name.clone(),
value: result,
value: result_clone,
});
}
} else {

View File

@@ -1,8 +1,7 @@
use gethostname::gethostname;
use std::env;
use std::process;
use uzers::{get_current_uid, get_current_gid, get_user_by_uid, get_group_by_gid};
use crate::meta_plugin::{MetaPlugin, MetaPluginResponse};
use crate::meta_plugin::MetaPlugin;
#[derive(Debug, Clone, Default)]
pub struct CwdMetaPlugin {