refactor: Remove duplicated program info definitions in status mode
Co-authored-by: aider (openai/andrew.openrouter.qwen.qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -37,6 +37,7 @@ pub trait MetaPlugin {
|
||||
fn is_supported(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn create(&self) -> Result<Box<dyn Write>>;
|
||||
fn finalize(&mut self) -> io::Result<String>;
|
||||
|
||||
@@ -44,6 +45,11 @@ pub trait MetaPlugin {
|
||||
fn update(&mut self, data: &[u8]);
|
||||
|
||||
fn meta_name(&mut self) -> String;
|
||||
|
||||
// Get program information for display in status
|
||||
fn program_info(&self) -> Option<(&str, Vec<&str>)> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
@@ -117,6 +117,14 @@ impl MetaPlugin for MetaPluginProgram {
|
||||
fn meta_name(&mut self) -> String {
|
||||
self.meta_name.clone()
|
||||
}
|
||||
|
||||
fn program_info(&self) -> Option<(&str, Vec<&str>)> {
|
||||
if self.supported {
|
||||
Some((&self.program, self.args.iter().map(|s| s.as_str()).collect()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -147,29 +147,12 @@ fn build_meta_plugin_table(enabled_meta_plugins: &Vec<MetaPluginType>) -> Table
|
||||
},
|
||||
// For program-based plugins, show program info
|
||||
_ => {
|
||||
// Get the program info by downcasting to MetaPluginProgram
|
||||
// This is a bit hacky but necessary to get the program info
|
||||
let program_name = match meta_plugin_type {
|
||||
MetaPluginType::FileMagic => "file".to_string(),
|
||||
MetaPluginType::FileMime => "file".to_string(),
|
||||
MetaPluginType::FileEncoding => "file".to_string(),
|
||||
MetaPluginType::LineCount => "wc".to_string(),
|
||||
MetaPluginType::WordCount => "wc".to_string(),
|
||||
MetaPluginType::DigestMd5 => "md5sum".to_string(),
|
||||
_ => "".to_string(),
|
||||
};
|
||||
|
||||
let args = match meta_plugin_type {
|
||||
MetaPluginType::FileMagic => "-bE -",
|
||||
MetaPluginType::FileMime => "-b --mime-type -",
|
||||
MetaPluginType::FileEncoding => "-b --mime-encoding -",
|
||||
MetaPluginType::LineCount => "-l",
|
||||
MetaPluginType::WordCount => "-w",
|
||||
MetaPluginType::DigestMd5 => "",
|
||||
_ => "",
|
||||
};
|
||||
|
||||
(program_name, args.to_string())
|
||||
// Get program info from the meta plugin itself
|
||||
if let Some((program, args)) = meta_plugin.program_info() {
|
||||
(program.to_string(), args.join(" "))
|
||||
} else {
|
||||
("<NOT FOUND>".to_string(), "".to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user