From a7b46658ac069bc6e0c5e18755c8b210254cd6b1 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 3 Sep 2025 09:05:49 -0300 Subject: [PATCH] feat: display filter plugin information in status output Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) --- src/modes/status_plugins.rs | 60 +++++++++++++++++++++++++++++----- src/services/status_service.rs | 9 +++-- 2 files changed, 58 insertions(+), 11 deletions(-) diff --git a/src/modes/status_plugins.rs b/src/modes/status_plugins.rs index 1aa3742..bbf885b 100644 --- a/src/modes/status_plugins.rs +++ b/src/modes/status_plugins.rs @@ -122,7 +122,7 @@ fn build_compression_table(compression_info: &Vec) -> Table { compression_table } -fn build_filter_plugin_table() -> Table { +fn build_filter_plugin_table(filter_plugins: &Vec) -> 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 } diff --git a/src/services/status_service.rs b/src/services/status_service.rs index eb95bcb..55ae8e5 100644 --- a/src/services/status_service.rs +++ b/src/services/status_service.rs @@ -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 }