feat: display filter plugin information in status output
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -122,7 +122,7 @@ fn build_compression_table(compression_info: &Vec<CompressionInfo>) -> Table {
|
||||
compression_table
|
||||
}
|
||||
|
||||
fn build_filter_plugin_table() -> Table {
|
||||
fn build_filter_plugin_table(filter_plugins: &Vec<String>) -> Table {
|
||||
let mut filter_plugin_table = Table::new();
|
||||
if std::io::stdout().is_terminal() {
|
||||
filter_plugin_table.set_format(*FORMAT_BOX_CHARS);
|
||||
@@ -135,13 +135,57 @@ fn build_filter_plugin_table() -> Table {
|
||||
b->"Options",
|
||||
b->"Description"));
|
||||
|
||||
// For now, we'll use a placeholder since we don't have access to filter plugin information
|
||||
// In a real implementation, you would query the available filter plugins
|
||||
filter_plugin_table.add_row(Row::new(vec![
|
||||
Cell::new("No filter plugins available"),
|
||||
Cell::new("{}"),
|
||||
Cell::new(""),
|
||||
]));
|
||||
// Sort plugins by name
|
||||
let mut sorted_plugin_names = filter_plugins.clone();
|
||||
sorted_plugin_names.sort();
|
||||
|
||||
for plugin_name in sorted_plugin_names {
|
||||
// Get the plugin creator
|
||||
let filter_plugins_map = crate::filter_plugin::get_available_filter_plugins();
|
||||
if let Some(plugin_creator) = filter_plugins_map.get(&plugin_name) {
|
||||
// Create a temporary instance to get options
|
||||
let plugin = plugin_creator();
|
||||
|
||||
// Get options
|
||||
let options = plugin.options();
|
||||
|
||||
// Format options as YAML string
|
||||
let options_str = if options.is_empty() {
|
||||
"{}".to_string()
|
||||
} else {
|
||||
let options_map: std::collections::BTreeMap<_, _> = options
|
||||
.iter()
|
||||
.map(|opt| (opt.name.clone(), serde_yaml::to_value(opt).unwrap()))
|
||||
.collect();
|
||||
serde_yaml::to_string(&options_map)
|
||||
.unwrap_or_else(|_| "Unable to serialize options".to_string())
|
||||
.trim()
|
||||
.to_string()
|
||||
};
|
||||
|
||||
// Get description from the first option or use a default
|
||||
let description = if let Some(first_opt) = options.first() {
|
||||
first_opt.description.clone().unwrap_or_else(|| "Filter plugin".to_string())
|
||||
} else {
|
||||
"Filter plugin".to_string()
|
||||
};
|
||||
|
||||
filter_plugin_table.add_row(Row::new(vec![
|
||||
Cell::new(&plugin_name),
|
||||
Cell::new(&options_str),
|
||||
Cell::new(&description),
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
// If no filter plugins are available, add a row indicating that
|
||||
if filter_plugins.is_empty() {
|
||||
filter_plugin_table.add_row(Row::new(vec![
|
||||
Cell::new("No filter plugins available"),
|
||||
Cell::new("{}"),
|
||||
Cell::new(""),
|
||||
]));
|
||||
}
|
||||
|
||||
filter_plugin_table
|
||||
}
|
||||
|
||||
@@ -31,10 +31,13 @@ impl StatusService {
|
||||
Some(crate::compression_engine::default_compression_type())
|
||||
};
|
||||
|
||||
let status_info = generate_status_info(data_path, db_path, &meta_plugin_types, enabled_compression_type);
|
||||
let mut status_info = generate_status_info(data_path, db_path, &meta_plugin_types, enabled_compression_type);
|
||||
|
||||
// The options are now populated directly in generate_status_info
|
||||
// No need to modify them here
|
||||
// Add filter plugins information
|
||||
status_info.filter_plugins = filter_plugin::get_available_filter_plugins()
|
||||
.keys()
|
||||
.map(|name| name.clone())
|
||||
.collect();
|
||||
|
||||
status_info
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user