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:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user