From 15417eb1d3413960ef8ccf6d185f4c9ac28275fa Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Mon, 8 Sep 2025 17:59:58 -0300 Subject: [PATCH] fix: Use `comfy-table` crate for table rendering Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) --- Cargo.toml | 2 +- src/modes/status.rs | 21 ++++++++-------- src/modes/status_plugins.rs | 50 ++++++++++++++++++------------------- 3 files changed, 37 insertions(+), 36 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 49a36e6..15b8f24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ lz4_flex = "0.11.1" magic = "0.13.0" nix = "0.30.1" once_cell = "1.19.0" -prettytable-rs = "0.10.0" +comfy-table = "0.3.1" pwhash = "1.0.0" regex = "1.9.5" ringbuf = "0.3" diff --git a/src/modes/status.rs b/src/modes/status.rs index ac5dc14..86a3179 100644 --- a/src/modes/status.rs +++ b/src/modes/status.rs @@ -9,15 +9,16 @@ use crate::config; use crate::common::status::StatusInfo; use serde_json; use serde_yaml; -use prettytable::{Attr, Cell, Row, Table}; -use prettytable::format::consts::{FORMAT_BOX_CHARS, FORMAT_NO_BORDER_LINE_SEPARATOR}; +use comfy_table::{Table, ContentArrangement, Cell, Color}; +use comfy_table::presets::UTF8_FULL; +use comfy_table::modifiers::UTF8_ROUND_CORNERS; use crate::common::status::PathInfo; use crate::meta_plugin::MetaPluginType; use crate::meta_plugin::get_meta_plugin; -fn build_path_table(path_info: &PathInfo) -> ComfyTable { - let mut path_table = ComfyTable::new(); +fn build_path_table(path_info: &PathInfo) -> Table { + let mut path_table = Table::new(); if std::io::stdout().is_terminal() { path_table @@ -28,8 +29,8 @@ fn build_path_table(path_info: &PathInfo) -> ComfyTable { } path_table.set_header(vec![ - Cell::new("Type").add_attribute(comfytable::Attribute::Bold), - Cell::new("Path").add_attribute(comfytable::Attribute::Bold), + Cell::new("Type").add_attribute(comfy_table::Attribute::Bold), + Cell::new("Path").add_attribute(comfy_table::Attribute::Bold), ]); path_table.add_row(vec!["Data", &path_info.data]); @@ -39,8 +40,8 @@ fn build_path_table(path_info: &PathInfo) -> ComfyTable { } -fn build_config_table(settings: &config::Settings) -> ComfyTable { - let mut config_table = ComfyTable::new(); +fn build_config_table(settings: &config::Settings) -> Table { + let mut config_table = Table::new(); if std::io::stdout().is_terminal() { config_table .load_preset(UTF8_FULL) @@ -50,8 +51,8 @@ fn build_config_table(settings: &config::Settings) -> ComfyTable { } config_table.set_header(vec![ - Cell::new("Setting").add_attribute(comfytable::Attribute::Bold), - Cell::new("Value").add_attribute(comfytable::Attribute::Bold), + Cell::new("Setting").add_attribute(comfy_table::Attribute::Bold), + Cell::new("Value").add_attribute(comfy_table::Attribute::Bold), ]); // Add relevant configuration settings diff --git a/src/modes/status_plugins.rs b/src/modes/status_plugins.rs index 29d6c6e..6efc7c5 100644 --- a/src/modes/status_plugins.rs +++ b/src/modes/status_plugins.rs @@ -43,17 +43,17 @@ use crate::modes::common::OutputFormat; use crate::config; use serde_json; use serde_yaml; -use comfytable::{ComfyTable, ContentArrangement, Row, Cell, Alignment}; -use comfytable::presets::UTF8_FULL; -use comfytable::modifiers::UTF8_ROUND_CORNERS; +use comfy_table::{Table, ContentArrangement, Row, Cell, Color}; +use comfy_table::presets::UTF8_FULL; +use comfy_table::modifiers::UTF8_ROUND_CORNERS; use crate::meta_plugin::{MetaPluginType, get_meta_plugin}; use crate::common::status::{MetaPluginInfo, CompressionInfo}; use prettytable::color; -fn build_meta_plugin_table(meta_plugin_info: &std::collections::HashMap) -> ComfyTable { - let mut meta_plugin_table = ComfyTable::new(); +fn build_meta_plugin_table(meta_plugin_info: &std::collections::HashMap) -> Table { + let mut meta_plugin_table = Table::new(); if std::io::stdout().is_terminal() { meta_plugin_table .load_preset(UTF8_FULL) @@ -63,9 +63,9 @@ fn build_meta_plugin_table(meta_plugin_info: &std::collections::HashMap) -> ComfyTable { - let mut compression_table = ComfyTable::new(); +fn build_compression_table(compression_info: &Vec) -> Table { + let mut compression_table = Table::new(); if std::io::stdout().is_terminal() { compression_table .load_preset(UTF8_FULL) @@ -131,27 +131,27 @@ fn build_compression_table(compression_info: &Vec) -> ComfyTabl } compression_table.set_header(vec![ - Cell::new("Type").add_attribute(comfytable::Attribute::Bold), - Cell::new("Found").add_attribute(comfytable::Attribute::Bold), - Cell::new("Enabled").add_attribute(comfytable::Attribute::Bold), - Cell::new("Binary").add_attribute(comfytable::Attribute::Bold), - Cell::new("Compress").add_attribute(comfytable::Attribute::Bold), - Cell::new("Decompress").add_attribute(comfytable::Attribute::Bold), + 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), ]); for info in compression_info { compression_table.add_row(vec![ info.compression_type.clone(), match info.found { - true => Cell::new("Yes").fg(comfytable::Color::Green), - false => Cell::new("No").fg(comfytable::Color::Red), + true => Cell::new("Yes").fg(Color::Green), + false => Cell::new("No").fg(Color::Red), }, match info.default { - true => Cell::new("Yes").fg(comfytable::Color::Green), + true => Cell::new("Yes").fg(Color::Green), false => Cell::new("No"), }, match info.binary.as_str() { - "" => Cell::new(&info.binary).fg(comfytable::Color::DarkGrey), + "" => Cell::new(&info.binary).fg(Color::DarkGrey), _ => Cell::new(&info.binary), }, info.compress.clone(), @@ -162,8 +162,8 @@ fn build_compression_table(compression_info: &Vec) -> ComfyTabl compression_table } -fn build_filter_plugin_table(filter_plugins: &Vec) -> ComfyTable { - let mut filter_plugin_table = ComfyTable::new(); +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 .load_preset(UTF8_FULL) @@ -173,9 +173,9 @@ fn build_filter_plugin_table(filter_plugins: &Vec