fix: Use comfy-table crate for table rendering

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-09-08 17:59:58 -03:00
parent 007f5e2377
commit 15417eb1d3
3 changed files with 37 additions and 36 deletions

View File

@@ -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<String, MetaPluginInfo>) -> ComfyTable {
let mut meta_plugin_table = ComfyTable::new();
fn build_meta_plugin_table(meta_plugin_info: &std::collections::HashMap<String, MetaPluginInfo>) -> 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<String,
}
meta_plugin_table.set_header(vec![
Cell::new("Plugin Name").add_attribute(comfytable::Attribute::Bold),
Cell::new("Options").add_attribute(comfytable::Attribute::Bold),
Cell::new("Outputs").add_attribute(comfytable::Attribute::Bold),
Cell::new("Plugin Name").add_attribute(comfy_table::Attribute::Bold),
Cell::new("Options").add_attribute(comfy_table::Attribute::Bold),
Cell::new("Outputs").add_attribute(comfy_table::Attribute::Bold),
]);
// Sort meta plugin info by plugin name
@@ -120,8 +120,8 @@ fn build_meta_plugin_table(meta_plugin_info: &std::collections::HashMap<String,
meta_plugin_table
}
fn build_compression_table(compression_info: &Vec<CompressionInfo>) -> ComfyTable {
let mut compression_table = ComfyTable::new();
fn build_compression_table(compression_info: &Vec<CompressionInfo>) -> 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<CompressionInfo>) -> 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() {
"<INTERNAL>" => Cell::new(&info.binary).fg(comfytable::Color::DarkGrey),
"<INTERNAL>" => 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<CompressionInfo>) -> ComfyTabl
compression_table
}
fn build_filter_plugin_table(filter_plugins: &Vec<crate::common::status::FilterPluginInfo>) -> ComfyTable {
let mut filter_plugin_table = ComfyTable::new();
fn build_filter_plugin_table(filter_plugins: &Vec<crate::common::status::FilterPluginInfo>) -> 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<crate::common::status::FilterP
}
filter_plugin_table.set_header(vec![
Cell::new("Plugin Name").add_attribute(comfytable::Attribute::Bold),
Cell::new("Options").add_attribute(comfytable::Attribute::Bold),
Cell::new("Description").add_attribute(comfytable::Attribute::Bold),
Cell::new("Plugin Name").add_attribute(comfy_table::Attribute::Bold),
Cell::new("Options").add_attribute(comfy_table::Attribute::Bold),
Cell::new("Description").add_attribute(comfy_table::Attribute::Bold),
]);
// Sort plugins by name