From d7f4724f2674a793c1f05d6ba35df9e9df8d5c10 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Mon, 8 Sep 2025 18:07:58 -0300 Subject: [PATCH] refactor: Unify table styling with comfy-table in status and list modes Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) --- src/modes/list.rs | 24 +++++++++++++++--------- src/modes/status.rs | 17 ++++++++--------- src/modes/status_plugins.rs | 27 +++++++++++++-------------- 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/modes/list.rs b/src/modes/list.rs index 000a32f..f865774 100644 --- a/src/modes/list.rs +++ b/src/modes/list.rs @@ -5,8 +5,9 @@ use crate::modes::common::ColumnType; use crate::modes::common::{size_column, string_column, OutputFormat}; use anyhow::{Result}; use log::debug; -use prettytable::format::Alignment; -use prettytable::{color, row, Attr, Cell, Row, Table}; +use comfy_table::{Table, ContentArrangement, Cell, Color, Attribute}; +use comfy_table::presets::UTF8_FULL; +use comfy_table::modifiers::UTF8_ROUND_CORNERS; use serde::{Deserialize, Serialize}; use serde_json; use serde_yaml; @@ -60,15 +61,20 @@ pub fn mode_list( debug!("Terminal width: {}", term_width); let mut table = Table::new(); - table.set_format(*prettytable::format::consts::FORMAT_CLEAN); - - let mut title_row = row!(); - - for column in &settings.list_format { - title_row.add_cell(Cell::new(&column.label).with_style(Attr::Bold)); + if stdout().is_terminal() { + table + .load_preset(UTF8_FULL) + .apply_modifier(UTF8_ROUND_CORNERS); + } else { + table.set_content_arrangement(ContentArrangement::Dynamic); } - table.set_titles(title_row); + // Create header row + let mut header_cells = Vec::new(); + for column in &settings.list_format { + header_cells.push(Cell::new(&column.label).add_attribute(Attribute::Bold)); + } + table.set_header(header_cells); for item_with_meta in items_with_meta { let tags: Vec = item_with_meta.tags.iter().map(|t| t.name.clone()).collect(); diff --git a/src/modes/status.rs b/src/modes/status.rs index 090fbbb..823cef4 100644 --- a/src/modes/status.rs +++ b/src/modes/status.rs @@ -9,10 +9,9 @@ use crate::config; use crate::common::status::StatusInfo; use serde_json; use serde_yaml; -use comfy_table::{Table, ContentArrangement, Cell, Color}; +use comfy_table::{Table, ContentArrangement, Cell, Color, Attribute}; use comfy_table::presets::UTF8_FULL; use comfy_table::modifiers::UTF8_ROUND_CORNERS; -use comfy_table::TableComponent; use crate::common::status::PathInfo; use crate::meta_plugin::MetaPluginType; @@ -30,8 +29,8 @@ fn build_path_table(path_info: &PathInfo) -> Table { } path_table.set_header(vec![ - Cell::new("Type").add_attribute(comfy_table::Attribute::Bold), - Cell::new("Path").add_attribute(comfy_table::Attribute::Bold), + Cell::new("Type").add_attribute(Attribute::Bold), + Cell::new("Path").add_attribute(Attribute::Bold), ]); path_table.add_row(vec!["Data", &path_info.data]); @@ -52,8 +51,8 @@ fn build_config_table(settings: &config::Settings) -> Table { } config_table.set_header(vec![ - Cell::new("Setting").add_attribute(comfy_table::Attribute::Bold), - Cell::new("Value").add_attribute(comfy_table::Attribute::Bold), + Cell::new("Setting").add_attribute(Attribute::Bold), + Cell::new("Value").add_attribute(Attribute::Bold), ]); // Add relevant configuration settings @@ -92,9 +91,9 @@ fn build_meta_plugins_configured_table(status_info: &StatusInfo) -> Option) -> Table { } compression_table.set_header(vec![ - Cell::new("Type").add_attribute(comfy_table::Attribute::Bold), - Cell::new("Found").add_attribute(comfy_table::Attribute::Bold), - Cell::new("Enabled").add_attribute(comfy_table::Attribute::Bold), - Cell::new("Binary").add_attribute(comfy_table::Attribute::Bold), - Cell::new("Compress").add_attribute(comfy_table::Attribute::Bold), - Cell::new("Decompress").add_attribute(comfy_table::Attribute::Bold), + Cell::new("Type").add_attribute(Attribute::Bold), + Cell::new("Found").add_attribute(Attribute::Bold), + Cell::new("Enabled").add_attribute(Attribute::Bold), + Cell::new("Binary").add_attribute(Attribute::Bold), + Cell::new("Compress").add_attribute(Attribute::Bold), + Cell::new("Decompress").add_attribute(Attribute::Bold), ]); for info in compression_info { @@ -173,9 +172,9 @@ fn build_filter_plugin_table(filter_plugins: &Vec