refactor: Improve comfy_table usage and consistency

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 18:19:10 -03:00
parent fb19499383
commit bf257b5ff3
4 changed files with 56 additions and 49 deletions

View File

@@ -69,12 +69,13 @@ fn show_item(
let item_tags: Vec<String> = item_with_meta.tags.iter().map(|t| t.name.clone()).collect(); let item_tags: Vec<String> = item_with_meta.tags.iter().map(|t| t.name.clone()).collect();
let mut table = Table::new(); let mut table = Table::new();
if std::io::stdout().is_terminal() {
table table
.load_preset(UTF8_FULL) .load_preset(UTF8_FULL)
.apply_modifier(UTF8_ROUND_CORNERS); .apply_modifier(UTF8_ROUND_CORNERS)
} else { .set_content_arrangement(ContentArrangement::Dynamic);
table.set_content_arrangement(ContentArrangement::Dynamic);
if !std::io::stdout().is_terminal() {
table.force_no_tty();
} }
// Add all the rows // Add all the rows

View File

@@ -62,12 +62,13 @@ pub fn mode_list(
debug!("Terminal width: {}", term_width); debug!("Terminal width: {}", term_width);
let mut table = Table::new(); let mut table = Table::new();
if stdout().is_terminal() {
table table
.load_preset(UTF8_FULL) .load_preset(UTF8_FULL)
.apply_modifier(UTF8_ROUND_CORNERS); .apply_modifier(UTF8_ROUND_CORNERS)
} else { .set_content_arrangement(ContentArrangement::Dynamic);
table.set_content_arrangement(ContentArrangement::Dynamic);
if !stdout().is_terminal() {
table.force_no_tty();
} }
// Create header row // Create header row

View File

@@ -19,13 +19,13 @@ use crate::meta_plugin::get_meta_plugin;
fn build_path_table(path_info: &PathInfo) -> Table { fn build_path_table(path_info: &PathInfo) -> Table {
let mut path_table = Table::new(); let mut path_table = Table::new();
if std::io::stdout().is_terminal() {
path_table path_table
.load_preset(UTF8_FULL) .load_preset(UTF8_FULL)
.apply_modifier(UTF8_ROUND_CORNERS); .apply_modifier(UTF8_ROUND_CORNERS)
} else { .set_content_arrangement(ContentArrangement::Dynamic);
path_table.set_content_arrangement(ContentArrangement::Dynamic);
if !std::io::stdout().is_terminal() {
path_table.force_no_tty();
} }
path_table.set_header(vec![ path_table.set_header(vec![
@@ -42,12 +42,13 @@ fn build_path_table(path_info: &PathInfo) -> Table {
fn build_config_table(settings: &config::Settings) -> Table { fn build_config_table(settings: &config::Settings) -> Table {
let mut config_table = Table::new(); let mut config_table = Table::new();
if std::io::stdout().is_terminal() {
config_table config_table
.load_preset(UTF8_FULL) .load_preset(UTF8_FULL)
.apply_modifier(UTF8_ROUND_CORNERS); .apply_modifier(UTF8_ROUND_CORNERS)
} else { .set_content_arrangement(ContentArrangement::Dynamic);
config_table.set_content_arrangement(ContentArrangement::Dynamic);
if !std::io::stdout().is_terminal() {
config_table.force_no_tty();
} }
config_table.set_header(vec![ config_table.set_header(vec![
@@ -82,12 +83,13 @@ fn build_meta_plugins_configured_table(status_info: &StatusInfo) -> Option<Table
sorted_meta_plugins.sort_by(|a, b| a.name.cmp(&b.name)); sorted_meta_plugins.sort_by(|a, b| a.name.cmp(&b.name));
let mut table = Table::new(); let mut table = Table::new();
if std::io::stdout().is_terminal() {
table table
.load_preset(UTF8_FULL) .load_preset(UTF8_FULL)
.apply_modifier(UTF8_ROUND_CORNERS); .apply_modifier(UTF8_ROUND_CORNERS)
} else { .set_content_arrangement(ContentArrangement::Dynamic);
table.set_content_arrangement(ContentArrangement::Dynamic);
if !std::io::stdout().is_terminal() {
table.force_no_tty();
} }
table.set_header(vec![ table.set_header(vec![

View File

@@ -53,12 +53,13 @@ use crate::common::status::{MetaPluginInfo, CompressionInfo};
fn build_meta_plugin_table(meta_plugin_info: &std::collections::HashMap<String, MetaPluginInfo>) -> Table { fn build_meta_plugin_table(meta_plugin_info: &std::collections::HashMap<String, MetaPluginInfo>) -> Table {
let mut meta_plugin_table = Table::new(); let mut meta_plugin_table = Table::new();
if std::io::stdout().is_terminal() {
meta_plugin_table meta_plugin_table
.load_preset(UTF8_FULL) .load_preset(UTF8_FULL)
.apply_modifier(UTF8_ROUND_CORNERS); .apply_modifier(UTF8_ROUND_CORNERS)
} else { .set_content_arrangement(ContentArrangement::Dynamic);
meta_plugin_table.set_content_arrangement(ContentArrangement::Dynamic);
if !std::io::stdout().is_terminal() {
meta_plugin_table.force_no_tty();
} }
meta_plugin_table.set_header(vec![ meta_plugin_table.set_header(vec![
@@ -121,12 +122,13 @@ fn build_meta_plugin_table(meta_plugin_info: &std::collections::HashMap<String,
fn build_compression_table(compression_info: &Vec<CompressionInfo>) -> Table { fn build_compression_table(compression_info: &Vec<CompressionInfo>) -> Table {
let mut compression_table = Table::new(); let mut compression_table = Table::new();
if std::io::stdout().is_terminal() {
compression_table compression_table
.load_preset(UTF8_FULL) .load_preset(UTF8_FULL)
.apply_modifier(UTF8_ROUND_CORNERS); .apply_modifier(UTF8_ROUND_CORNERS)
} else { .set_content_arrangement(ContentArrangement::Dynamic);
compression_table.set_content_arrangement(ContentArrangement::Dynamic);
if !std::io::stdout().is_terminal() {
compression_table.force_no_tty();
} }
compression_table.set_header(vec![ compression_table.set_header(vec![
@@ -160,12 +162,13 @@ fn build_compression_table(compression_info: &Vec<CompressionInfo>) -> Table {
fn build_filter_plugin_table(filter_plugins: &Vec<crate::common::status::FilterPluginInfo>) -> Table { fn build_filter_plugin_table(filter_plugins: &Vec<crate::common::status::FilterPluginInfo>) -> Table {
let mut filter_plugin_table = Table::new(); let mut filter_plugin_table = Table::new();
if std::io::stdout().is_terminal() {
filter_plugin_table filter_plugin_table
.load_preset(UTF8_FULL) .load_preset(UTF8_FULL)
.apply_modifier(UTF8_ROUND_CORNERS); .apply_modifier(UTF8_ROUND_CORNERS)
} else { .set_content_arrangement(ContentArrangement::Dynamic);
filter_plugin_table.set_content_arrangement(ContentArrangement::Dynamic);
if !std::io::stdout().is_terminal() {
filter_plugin_table.force_no_tty();
} }
filter_plugin_table.set_header(vec![ filter_plugin_table.set_header(vec![