From 923ed65d427f4b0cac6df1851bcd8694d9a862cc Mon Sep 17 00:00:00 2001 From: "Andrew Phillips (aider)" Date: Thu, 22 May 2025 13:04:46 -0300 Subject: [PATCH] feat: add meta plugins table to status mode --- src/modes/status.rs | 60 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/modes/status.rs b/src/modes/status.rs index ae6a466..f35c36a 100644 --- a/src/modes/status.rs +++ b/src/modes/status.rs @@ -14,6 +14,11 @@ use prettytable::color; 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; + fn build_path_table(data_path: PathBuf, db_path: PathBuf) -> Table { let mut path_table = Table::new(); @@ -164,6 +169,58 @@ fn build_digest_table() -> Table { digest_table } +fn build_meta_plugin_table() -> Table { + let mut meta_plugin_table = Table::new(); + if std::io::stdout().is_terminal() { + meta_plugin_table.set_format(*FORMAT_BOX_CHARS_NO_BORDER_LINE_SEPARATOR); + } else { + meta_plugin_table.set_format(*FORMAT_NO_BORDER_LINE_SEPARATOR); + } + + meta_plugin_table.set_titles(row!( + b->"Type", + b->"Found", + b->"Default", + b->"Binary", + b->"Args")); + + let default_type = meta_plugin::default_meta_plugin_type(); + + for meta_plugin_type in MetaPluginType::iter() { + let meta_plugin_program: MetaPluginProgram = match &META_PLUGIN_PROGRAMS[meta_plugin_type.clone()] { + Some(meta_plugin_program) => meta_plugin_program.clone(), + None => MetaPluginProgram { + program: "".to_string(), + args: Vec::new(), + supported: true, + }, + }; + + let is_default = meta_plugin_type == default_type; + + meta_plugin_table.add_row(Row::new(vec![ + Cell::new(&meta_plugin_type.to_string()), + match meta_plugin_program.supported { + true => Cell::new("Yes").with_style(Attr::ForegroundColor(color::GREEN)), + false => Cell::new("No").with_style(Attr::ForegroundColor(color::RED)), + }, + match is_default { + true => Cell::new("Yes").with_style(Attr::ForegroundColor(color::GREEN)), + false => Cell::new("No"), + }, + match meta_plugin_program.program.is_empty() { + true => { + Cell::new("").with_style(Attr::ForegroundColor(color::BRIGHT_BLACK)) + } + false => Cell::new(&meta_plugin_program.program), + }, + Cell::new(&meta_plugin_program.args.join(" ")), + ])); + } + + meta_plugin_table +} + pub fn mode_status( _cmd: &mut Command, _args: &crate::Args, @@ -178,5 +235,8 @@ pub fn mode_status( println!(); println!("DIGEST:"); build_digest_table().printstd(); + println!(); + println!("META PLUGINS:"); + build_meta_plugin_table().printstd(); Ok(()) }