refactor: replace meta_name with MetaPluginType from strum
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -126,8 +126,8 @@ impl MetaPlugin for BinaryMetaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
self.base.meta_name.clone()
|
||||
fn meta_type(&self) -> MetaPluginType {
|
||||
MetaPluginType::Binary
|
||||
}
|
||||
|
||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
|
||||
@@ -9,7 +9,6 @@ pub struct MetaPluginCommand {
|
||||
pub program: String,
|
||||
pub args: Vec<String>,
|
||||
pub supported: bool,
|
||||
pub meta_name: String,
|
||||
pub split_whitespace: bool,
|
||||
process: Option<Child>,
|
||||
writer: Option<Box<dyn Write>>,
|
||||
@@ -67,7 +66,6 @@ impl MetaPluginCommand {
|
||||
program: program_path.map_or_else(|_| program.to_string(), |p| p.to_string_lossy().to_string()),
|
||||
args: args.iter().map(|s| s.to_string()).collect(),
|
||||
supported,
|
||||
meta_name,
|
||||
split_whitespace,
|
||||
process: None,
|
||||
writer: None,
|
||||
@@ -158,7 +156,7 @@ impl MetaPlugin for MetaPluginCommand {
|
||||
|
||||
// Use process_metadata_outputs to handle output mapping
|
||||
if let Some(meta_data) = crate::meta_plugin::process_metadata_outputs(
|
||||
&self.meta_name,
|
||||
&self.meta_type().to_string(),
|
||||
serde_yaml::Value::String(result),
|
||||
&self.outputs
|
||||
) {
|
||||
@@ -192,8 +190,8 @@ impl MetaPlugin for MetaPluginCommand {
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
self.meta_name.clone()
|
||||
fn meta_type(&self) -> MetaPluginType {
|
||||
MetaPluginType::Command
|
||||
}
|
||||
|
||||
fn program_info(&self) -> Option<(&str, Vec<&str>)> {
|
||||
|
||||
@@ -69,8 +69,8 @@ impl MetaPlugin for CwdMetaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
self.meta_name.clone()
|
||||
fn meta_type(&self) -> MetaPluginType {
|
||||
MetaPluginType::Cwd
|
||||
}
|
||||
|
||||
fn initialize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
|
||||
@@ -218,8 +218,8 @@ impl MetaPlugin for DigestMetaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
self.meta_name.clone()
|
||||
fn meta_type(&self) -> MetaPluginType {
|
||||
MetaPluginType::Digest
|
||||
}
|
||||
|
||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
|
||||
@@ -223,8 +223,8 @@ impl MetaPlugin for HostnameMetaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
self.meta_name.clone()
|
||||
fn meta_type(&self) -> MetaPluginType {
|
||||
MetaPluginType::Hostname
|
||||
}
|
||||
|
||||
fn initialize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
|
||||
@@ -86,8 +86,8 @@ impl MetaPlugin for KeepPidMetaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
self.meta_name.clone()
|
||||
fn meta_type(&self) -> MetaPluginType {
|
||||
MetaPluginType::KeepPid
|
||||
}
|
||||
|
||||
fn initialize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
|
||||
@@ -207,8 +207,8 @@ impl MetaPlugin for MagicFileMetaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
"magic_file".to_string()
|
||||
fn meta_type(&self) -> MetaPluginType {
|
||||
MetaPluginType::MagicFile
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -185,9 +185,15 @@ pub fn process_metadata_outputs(internal_name: &str, value: serde_yaml::Value, o
|
||||
}
|
||||
|
||||
pub trait MetaPlugin where Self: 'static {
|
||||
fn meta_type(&self) -> MetaPluginType;
|
||||
|
||||
// For backward compatibility, provide meta_name() that uses meta_type()
|
||||
fn meta_name(&self) -> String {
|
||||
self.meta_type().to_string()
|
||||
}
|
||||
|
||||
fn is_supported(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn is_internal(&self) -> bool {
|
||||
true
|
||||
@@ -218,7 +224,7 @@ pub trait MetaPlugin where Self: 'static {
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String;
|
||||
fn meta_type(&self) -> MetaPluginType;
|
||||
|
||||
// Get program information for display in status
|
||||
fn program_info(&self) -> Option<(&str, Vec<&str>)> {
|
||||
@@ -294,7 +300,7 @@ pub fn get_meta_plugin(
|
||||
// For command type, we need to parse the command from options
|
||||
let mut program_name = String::new();
|
||||
let mut args = Vec::new();
|
||||
let mut meta_name = "command".to_string();
|
||||
let meta_name = MetaPluginType::Command.to_string();
|
||||
let mut split_whitespace = true;
|
||||
|
||||
if let Some(opts) = &options {
|
||||
|
||||
@@ -115,8 +115,8 @@ impl MetaPlugin for ReadRateMetaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
self.meta_name.clone()
|
||||
fn meta_type(&self) -> MetaPluginType {
|
||||
MetaPluginType::ReadRate
|
||||
}
|
||||
|
||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
|
||||
@@ -108,8 +108,8 @@ impl MetaPlugin for ReadTimeMetaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
self.meta_name.clone()
|
||||
fn meta_type(&self) -> MetaPluginType {
|
||||
MetaPluginType::ReadTime
|
||||
}
|
||||
|
||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
|
||||
@@ -86,8 +86,8 @@ impl MetaPlugin for ShellMetaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
self.meta_name.clone()
|
||||
fn meta_type(&self) -> MetaPluginType {
|
||||
MetaPluginType::Shell
|
||||
}
|
||||
|
||||
fn initialize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
|
||||
@@ -87,8 +87,8 @@ impl MetaPlugin for ShellPidMetaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
self.meta_name.clone()
|
||||
fn meta_type(&self) -> MetaPluginType {
|
||||
MetaPluginType::ShellPid
|
||||
}
|
||||
|
||||
fn initialize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
|
||||
|
||||
@@ -583,8 +583,8 @@ impl MetaPlugin for TextMetaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
self.base.meta_name.clone()
|
||||
fn meta_type(&self) -> MetaPluginType {
|
||||
MetaPluginType::Text
|
||||
}
|
||||
|
||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
|
||||
@@ -71,8 +71,8 @@ impl MetaPlugin for UserMetaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
self.base.meta_name.clone()
|
||||
fn meta_type(&self) -> MetaPluginType {
|
||||
MetaPluginType::User
|
||||
}
|
||||
|
||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
|
||||
Reference in New Issue
Block a user