fix: Correct table cell alignment and string conversion

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:12:22 -03:00
parent 9f328a376f
commit 1a0478a545
4 changed files with 30 additions and 34 deletions

View File

@@ -9,7 +9,6 @@ use clap::error::ErrorKind;
use std::path::PathBuf; use std::path::PathBuf;
use crate::services::item_service::ItemService; use crate::services::item_service::ItemService;
use crate::modes::common::get_format_box_chars_no_border_line_separator;
use chrono::prelude::*; use chrono::prelude::*;
use is_terminal::IsTerminal; use is_terminal::IsTerminal;
use comfy_table::{Table, ContentArrangement, Cell, Attribute}; use comfy_table::{Table, ContentArrangement, Cell, Attribute};

View File

@@ -145,10 +145,10 @@ pub fn mode_list(
Cell::new(&string_column(item.id.unwrap_or(0).to_string(), column_width)); Cell::new(&string_column(item.id.unwrap_or(0).to_string(), column_width));
match column.align { match column.align {
crate::config::ColumnAlignment::Right => { crate::config::ColumnAlignment::Right => {
cell = cell.alignment(CellAlignment::Right); cell = cell.set_alignment(CellAlignment::Right);
} }
crate::config::ColumnAlignment::Left => { crate::config::ColumnAlignment::Left => {
cell = cell.alignment(CellAlignment::Left); cell = cell.set_alignment(CellAlignment::Left);
} }
} }
cell cell
@@ -163,10 +163,10 @@ pub fn mode_list(
)); ));
match column.align { match column.align {
crate::config::ColumnAlignment::Right => { crate::config::ColumnAlignment::Right => {
cell.align(Alignment::RIGHT); cell = cell.set_alignment(CellAlignment::Right);
} }
crate::config::ColumnAlignment::Left => { crate::config::ColumnAlignment::Left => {
cell.align(Alignment::LEFT); cell = cell.set_alignment(CellAlignment::Left);
} }
} }
cell cell
@@ -180,10 +180,10 @@ pub fn mode_list(
)); ));
match column.align { match column.align {
crate::config::ColumnAlignment::Right => { crate::config::ColumnAlignment::Right => {
cell.align(Alignment::RIGHT); cell = cell.set_alignment(CellAlignment::Right);
} }
crate::config::ColumnAlignment::Left => { crate::config::ColumnAlignment::Left => {
cell.align(Alignment::LEFT); cell = cell.set_alignment(CellAlignment::Left);
} }
} }
cell cell
@@ -199,10 +199,10 @@ pub fn mode_list(
}; };
match column.align { match column.align {
crate::config::ColumnAlignment::Right => { crate::config::ColumnAlignment::Right => {
cell.align(Alignment::RIGHT); cell = cell.set_alignment(CellAlignment::Right);
} }
crate::config::ColumnAlignment::Left => { crate::config::ColumnAlignment::Left => {
cell.align(Alignment::LEFT); cell = cell.set_alignment(CellAlignment::Left);
} }
} }
cell cell
@@ -213,10 +213,10 @@ pub fn mode_list(
Cell::new(&string_column(item.compression.to_string(), column_width)); Cell::new(&string_column(item.compression.to_string(), column_width));
match column.align { match column.align {
crate::config::ColumnAlignment::Right => { crate::config::ColumnAlignment::Right => {
cell.align(Alignment::RIGHT); cell = cell.set_alignment(CellAlignment::Right);
} }
crate::config::ColumnAlignment::Left => { crate::config::ColumnAlignment::Left => {
cell.align(Alignment::LEFT); cell = cell.set_alignment(CellAlignment::Left);
} }
} }
cell cell
@@ -230,10 +230,10 @@ pub fn mode_list(
)); ));
match column.align { match column.align {
crate::config::ColumnAlignment::Right => { crate::config::ColumnAlignment::Right => {
cell.align(Alignment::RIGHT); cell = cell.set_alignment(CellAlignment::Right);
} }
crate::config::ColumnAlignment::Left => { crate::config::ColumnAlignment::Left => {
cell.align(Alignment::LEFT); cell = cell.set_alignment(CellAlignment::Left);
} }
} }
cell cell
@@ -244,10 +244,10 @@ pub fn mode_list(
.add_attribute(Attribute::Bold); .add_attribute(Attribute::Bold);
match column.align { match column.align {
crate::config::ColumnAlignment::Right => { crate::config::ColumnAlignment::Right => {
cell.align(Alignment::RIGHT); cell = cell.set_alignment(CellAlignment::Right);
} }
crate::config::ColumnAlignment::Left => { crate::config::ColumnAlignment::Left => {
cell.align(Alignment::LEFT); cell = cell.set_alignment(CellAlignment::Left);
} }
} }
cell cell
@@ -260,10 +260,10 @@ pub fn mode_list(
)); ));
match column.align { match column.align {
crate::config::ColumnAlignment::Right => { crate::config::ColumnAlignment::Right => {
cell.align(Alignment::RIGHT); cell = cell.set_alignment(CellAlignment::Right);
} }
crate::config::ColumnAlignment::Left => { crate::config::ColumnAlignment::Left => {
cell.align(Alignment::LEFT); cell = cell.set_alignment(CellAlignment::Left);
} }
} }
cell cell
@@ -272,10 +272,10 @@ pub fn mode_list(
let mut cell = Cell::new(&string_column(tags.join(" "), column_width)); let mut cell = Cell::new(&string_column(tags.join(" "), column_width));
match column.align { match column.align {
crate::config::ColumnAlignment::Right => { crate::config::ColumnAlignment::Right => {
cell.align(Alignment::RIGHT); cell = cell.set_alignment(CellAlignment::Right);
} }
crate::config::ColumnAlignment::Left => { crate::config::ColumnAlignment::Left => {
cell.align(Alignment::LEFT); cell = cell.set_alignment(CellAlignment::Left);
} }
} }
cell cell
@@ -287,10 +287,10 @@ pub fn mode_list(
Cell::new(&string_column(meta_value.to_string(), column_width)); Cell::new(&string_column(meta_value.to_string(), column_width));
match column.align { match column.align {
crate::config::ColumnAlignment::Right => { crate::config::ColumnAlignment::Right => {
cell.align(Alignment::RIGHT); cell = cell.set_alignment(CellAlignment::Right);
} }
crate::config::ColumnAlignment::Left => { crate::config::ColumnAlignment::Left => {
cell.align(Alignment::LEFT); cell = cell.set_alignment(CellAlignment::Left);
} }
} }
cell cell
@@ -299,10 +299,10 @@ pub fn mode_list(
let mut cell = Cell::new(""); let mut cell = Cell::new("");
match column.align { match column.align {
crate::config::ColumnAlignment::Right => { crate::config::ColumnAlignment::Right => {
cell.align(Alignment::RIGHT); cell = cell.set_alignment(CellAlignment::Right);
} }
crate::config::ColumnAlignment::Left => { crate::config::ColumnAlignment::Left => {
cell.align(Alignment::LEFT); cell = cell.set_alignment(CellAlignment::Left);
} }
} }
cell cell
@@ -312,10 +312,10 @@ pub fn mode_list(
let mut cell = Cell::new(""); let mut cell = Cell::new("");
match column.align { match column.align {
crate::config::ColumnAlignment::Right => { crate::config::ColumnAlignment::Right => {
cell.align(Alignment::RIGHT); cell = cell.set_alignment(CellAlignment::Right);
} }
crate::config::ColumnAlignment::Left => { crate::config::ColumnAlignment::Left => {
cell.align(Alignment::LEFT); cell = cell.set_alignment(CellAlignment::Left);
} }
} }
cell cell

View File

@@ -4,7 +4,7 @@ use std::path::PathBuf;
use std::str::FromStr; use std::str::FromStr;
use log::debug; use log::debug;
use crate::modes::common::{get_format_box_chars_no_border_line_separator, OutputFormat}; use crate::modes::common::OutputFormat;
use crate::config; use crate::config;
use crate::common::status::StatusInfo; use crate::common::status::StatusInfo;
use serde_json; use serde_json;

View File

@@ -142,17 +142,14 @@ fn build_compression_table(compression_info: &Vec<CompressionInfo>) -> Table {
compression_table.add_row(vec![ compression_table.add_row(vec![
info.compression_type.clone(), info.compression_type.clone(),
match info.found { match info.found {
true => Cell::new("Yes").fg(Color::Green).to_string(), true => "Yes".to_string(),
false => Cell::new("No").fg(Color::Red).to_string(), false => "No".to_string(),
}, },
match info.default { match info.default {
true => Cell::new("Yes").fg(Color::Green).to_string(), true => "Yes".to_string(),
false => Cell::new("No").to_string(), false => "No".to_string(),
},
match info.binary.as_str() {
"<INTERNAL>" => Cell::new(&info.binary).fg(Color::DarkGrey).to_string(),
_ => info.binary.clone(),
}, },
info.binary.clone(),
info.compress.clone(), info.compress.clone(),
info.decompress.clone(), info.decompress.clone(),
]); ]);