refactor: merge get_meta_plugin_with_config into get_meta_plugin
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -255,36 +255,15 @@ pub trait MetaPlugin where Self: 'static {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_meta_plugin(meta_plugin_type: MetaPluginType) -> Box<dyn MetaPlugin> {
|
pub fn get_meta_plugin(
|
||||||
// Use new(None, None) which passes None for options and outputs
|
|
||||||
match meta_plugin_type {
|
|
||||||
MetaPluginType::FileMagic => Box::new(MetaPluginProgram::new("file", vec!["-bE", "-"], "file_magic".to_string(), true, None, None)),
|
|
||||||
MetaPluginType::FileMime => Box::new(MetaPluginProgram::new("file", vec!["-b", "--mime-type", "-"], "file_mime".to_string(), true, None, None)),
|
|
||||||
MetaPluginType::FileEncoding => Box::new(MetaPluginProgram::new("file", vec!["-b", "--mime-encoding", "-"], "file_encoding".to_string(), true, None, None)),
|
|
||||||
MetaPluginType::MagicFile => Box::new(MagicFileMetaPlugin::new(None, None)),
|
|
||||||
MetaPluginType::LineCount => Box::new(MetaPluginProgram::new("wc", vec!["-l"], "line_count".to_string(), true, None, None)),
|
|
||||||
MetaPluginType::WordCount => Box::new(MetaPluginProgram::new("wc", vec!["-w"], "word_count".to_string(), true, None, None)),
|
|
||||||
MetaPluginType::Cwd => Box::new(CwdMetaPlugin::new(None, None)),
|
|
||||||
MetaPluginType::Binary => Box::new(BinaryMetaPlugin::new(None, None)),
|
|
||||||
MetaPluginType::Text => Box::new(TextMetaPlugin::new(None, None)),
|
|
||||||
MetaPluginType::User => Box::new(UserMetaPlugin::new(None, None)),
|
|
||||||
MetaPluginType::Shell => Box::new(ShellMetaPlugin::new(None, None)),
|
|
||||||
MetaPluginType::ShellPid => Box::new(ShellPidMetaPlugin::new(None, None)),
|
|
||||||
MetaPluginType::KeepPid => Box::new(KeepPidMetaPlugin::new(None, None)),
|
|
||||||
MetaPluginType::Digest => Box::new(DigestMetaPlugin::new(None, None)),
|
|
||||||
MetaPluginType::ReadTime => Box::new(ReadTimeMetaPlugin::new(None, None)),
|
|
||||||
MetaPluginType::ReadRate => Box::new(ReadRateMetaPlugin::new(None, None)),
|
|
||||||
MetaPluginType::Hostname => Box::new(HostnameMetaPlugin::new(None, None)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a new function to create plugins with options and outputs
|
|
||||||
pub fn get_meta_plugin_with_config(
|
|
||||||
meta_plugin_type: MetaPluginType,
|
meta_plugin_type: MetaPluginType,
|
||||||
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>>,
|
||||||
) -> Box<dyn MetaPlugin> {
|
) -> Box<dyn MetaPlugin> {
|
||||||
match meta_plugin_type {
|
match meta_plugin_type {
|
||||||
|
MetaPluginType::FileMagic => Box::new(MetaPluginProgram::new("file", vec!["-bE", "-"], "file_magic".to_string(), true, options, outputs)),
|
||||||
|
MetaPluginType::FileMime => Box::new(MetaPluginProgram::new("file", vec!["-b", "--mime-type", "-"], "file_mime".to_string(), true, options, outputs)),
|
||||||
|
MetaPluginType::FileEncoding => Box::new(MetaPluginProgram::new("file", vec!["-b", "--mime-encoding", "-"], "file_encoding".to_string(), true, options, outputs)),
|
||||||
MetaPluginType::MagicFile => Box::new(MagicFileMetaPlugin::new(options, outputs)),
|
MetaPluginType::MagicFile => Box::new(MagicFileMetaPlugin::new(options, outputs)),
|
||||||
MetaPluginType::LineCount => Box::new(MetaPluginProgram::new("wc", vec!["-l"], "line_count".to_string(), true, options, outputs)),
|
MetaPluginType::LineCount => Box::new(MetaPluginProgram::new("wc", vec!["-l"], "line_count".to_string(), true, options, outputs)),
|
||||||
MetaPluginType::WordCount => Box::new(MetaPluginProgram::new("wc", vec!["-w"], "word_count".to_string(), true, options, outputs)),
|
MetaPluginType::WordCount => Box::new(MetaPluginProgram::new("wc", vec!["-w"], "word_count".to_string(), true, options, outputs)),
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ impl ItemService {
|
|||||||
|
|
||||||
let mut plugins: Vec<Box<dyn MetaPlugin>> = plugin_types
|
let mut plugins: Vec<Box<dyn MetaPlugin>> = plugin_types
|
||||||
.iter()
|
.iter()
|
||||||
.map(|p| get_meta_plugin_with_config(p.clone(), None, None))
|
.map(|p| crate::meta_plugin::get_meta_plugin(p.clone(), None, None))
|
||||||
.collect();
|
.collect();
|
||||||
debug!("ITEM_SERVICE: Created {} meta plugins for MCP item", plugins.len());
|
debug!("ITEM_SERVICE: Created {} meta plugins for MCP item", plugins.len());
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ impl MetaService {
|
|||||||
(None, None)
|
(None, None)
|
||||||
};
|
};
|
||||||
|
|
||||||
get_meta_plugin_with_config(meta_plugin_type.clone(), options, outputs)
|
crate::meta_plugin::get_meta_plugin(meta_plugin_type.clone(), options, outputs)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user