refactor: remove META_PLUGIN_PROGRAMS and use get_meta_plugin() instead
Co-authored-by: aider (openai/andrew.openrouter.qwen.qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -15,9 +15,8 @@ use prettytable::row;
|
||||
use prettytable::{Attr, Cell, Row, Table};
|
||||
|
||||
use crate::meta_plugin;
|
||||
use crate::meta_plugin::META_PLUGIN_PROGRAMS;
|
||||
use crate::meta_plugin::MetaPluginType;
|
||||
use crate::meta_plugin::program::MetaPluginProgram;
|
||||
use crate::meta_plugin::get_meta_plugin;
|
||||
|
||||
fn build_path_table(data_path: PathBuf, db_path: PathBuf) -> Table {
|
||||
let mut path_table = Table::new();
|
||||
@@ -133,26 +132,45 @@ fn build_meta_plugin_table(enabled_meta_plugins: &Vec<MetaPluginType>) -> Table
|
||||
let is_supported = meta_plugin.is_supported();
|
||||
let is_enabled = enabled_meta_plugins.contains(&meta_plugin_type);
|
||||
|
||||
// Get program info for display purposes
|
||||
let meta_plugin_program: Option<MetaPluginProgram> = META_PLUGIN_PROGRAMS[meta_plugin_type.clone()].clone();
|
||||
|
||||
// Determine what implementation will actually be used
|
||||
let (binary_display, args_display) = match meta_plugin_type {
|
||||
// For internal plugins, always show as internal
|
||||
MetaPluginType::DigestSha256 | MetaPluginType::ReadTime | MetaPluginType::ReadRate => {
|
||||
MetaPluginType::DigestSha256 | MetaPluginType::ReadTime | MetaPluginType::ReadRate |
|
||||
MetaPluginType::Cwd | MetaPluginType::Uid | MetaPluginType::User |
|
||||
MetaPluginType::Gid | MetaPluginType::Group | MetaPluginType::Shell |
|
||||
MetaPluginType::ShellPid | MetaPluginType::KeepPid | MetaPluginType::Hostname |
|
||||
MetaPluginType::FullHostname => {
|
||||
("<INTERNAL>".to_string(), "".to_string())
|
||||
},
|
||||
// For program-based plugins, show program info if supported, otherwise show as not found
|
||||
_ => {
|
||||
match &meta_plugin_program {
|
||||
Some(program) => {
|
||||
if program.supported {
|
||||
(program.program.clone(), program.args.join(" "))
|
||||
} else {
|
||||
("<NOT FOUND>".to_string(), "".to_string())
|
||||
}
|
||||
},
|
||||
None => ("<INTERNAL>".to_string(), "".to_string()),
|
||||
// For program-based plugins, we need to check if they're supported
|
||||
if is_supported {
|
||||
// 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())
|
||||
} else {
|
||||
("<NOT FOUND>".to_string(), "".to_string())
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user