refactor: Migrate table display from prettytable to comfytable
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -16,75 +16,55 @@ use crate::common::status::PathInfo;
|
||||
use crate::meta_plugin::MetaPluginType;
|
||||
use crate::meta_plugin::get_meta_plugin;
|
||||
|
||||
fn build_path_table(path_info: &PathInfo) -> Table {
|
||||
let mut path_table = Table::new();
|
||||
fn build_path_table(path_info: &PathInfo) -> ComfyTable {
|
||||
let mut path_table = ComfyTable::new();
|
||||
|
||||
if std::io::stdout().is_terminal() {
|
||||
path_table.set_format(get_format_box_chars_no_border_line_separator());
|
||||
path_table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS);
|
||||
} else {
|
||||
path_table.set_format(*FORMAT_NO_BORDER_LINE_SEPARATOR);
|
||||
path_table.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
}
|
||||
|
||||
path_table.set_titles(Row::new(vec![
|
||||
Cell::new("Type").with_style(Attr::Bold),
|
||||
Cell::new("Path").with_style(Attr::Bold),
|
||||
]));
|
||||
path_table.set_header(vec![
|
||||
Cell::new("Type").add_attribute(comfytable::Attribute::Bold),
|
||||
Cell::new("Path").add_attribute(comfytable::Attribute::Bold),
|
||||
]);
|
||||
|
||||
path_table.add_row(Row::new(vec![
|
||||
Cell::new("Data"),
|
||||
Cell::new(&path_info.data),
|
||||
]));
|
||||
|
||||
path_table.add_row(Row::new(vec![
|
||||
Cell::new("Database"),
|
||||
Cell::new(&path_info.database),
|
||||
]));
|
||||
path_table.add_row(vec!["Data", &path_info.data]);
|
||||
path_table.add_row(vec!["Database", &path_info.database]);
|
||||
|
||||
path_table
|
||||
}
|
||||
|
||||
|
||||
fn build_config_table(settings: &config::Settings) -> Table {
|
||||
let mut config_table = Table::new();
|
||||
fn build_config_table(settings: &config::Settings) -> ComfyTable {
|
||||
let mut config_table = ComfyTable::new();
|
||||
if std::io::stdout().is_terminal() {
|
||||
config_table.set_format(get_format_box_chars_no_border_line_separator());
|
||||
config_table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS);
|
||||
} else {
|
||||
config_table.set_format(*FORMAT_NO_BORDER_LINE_SEPARATOR);
|
||||
config_table.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
}
|
||||
|
||||
config_table.set_titles(Row::new(vec![
|
||||
Cell::new("Setting").with_style(Attr::Bold),
|
||||
Cell::new("Value").with_style(Attr::Bold),
|
||||
]));
|
||||
config_table.set_header(vec![
|
||||
Cell::new("Setting").add_attribute(comfytable::Attribute::Bold),
|
||||
Cell::new("Value").add_attribute(comfytable::Attribute::Bold),
|
||||
]);
|
||||
|
||||
// Add relevant configuration settings
|
||||
config_table.add_row(Row::new(vec![
|
||||
Cell::new("Directory"),
|
||||
Cell::new(&settings.dir.to_string_lossy()),
|
||||
]));
|
||||
|
||||
config_table.add_row(Row::new(vec![
|
||||
Cell::new("Human Readable"),
|
||||
Cell::new(&settings.human_readable.to_string()),
|
||||
]));
|
||||
|
||||
config_table.add_row(Row::new(vec![
|
||||
Cell::new("Quiet"),
|
||||
Cell::new(&settings.quiet.to_string()),
|
||||
]));
|
||||
config_table.add_row(vec!["Directory", &settings.dir.to_string_lossy()]);
|
||||
config_table.add_row(vec!["Human Readable", &settings.human_readable.to_string()]);
|
||||
config_table.add_row(vec!["Quiet", &settings.quiet.to_string()]);
|
||||
|
||||
if let Some(output_format) = &settings.output_format {
|
||||
config_table.add_row(Row::new(vec![
|
||||
Cell::new("Output Format"),
|
||||
Cell::new(output_format),
|
||||
]));
|
||||
config_table.add_row(vec!["Output Format", output_format]);
|
||||
}
|
||||
|
||||
if let Some(compression) = settings.compression() {
|
||||
config_table.add_row(Row::new(vec![
|
||||
Cell::new("Compression"),
|
||||
Cell::new(&compression),
|
||||
]));
|
||||
config_table.add_row(vec!["Compression", &compression]);
|
||||
}
|
||||
|
||||
config_table
|
||||
|
||||
Reference in New Issue
Block a user