refactor: Unify table styling with comfy-table in status and list modes
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -5,8 +5,9 @@ use crate::modes::common::ColumnType;
|
||||
use crate::modes::common::{size_column, string_column, OutputFormat};
|
||||
use anyhow::{Result};
|
||||
use log::debug;
|
||||
use prettytable::format::Alignment;
|
||||
use prettytable::{color, row, Attr, Cell, Row, Table};
|
||||
use comfy_table::{Table, ContentArrangement, Cell, Color, Attribute};
|
||||
use comfy_table::presets::UTF8_FULL;
|
||||
use comfy_table::modifiers::UTF8_ROUND_CORNERS;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json;
|
||||
use serde_yaml;
|
||||
@@ -60,15 +61,20 @@ pub fn mode_list(
|
||||
debug!("Terminal width: {}", term_width);
|
||||
|
||||
let mut table = Table::new();
|
||||
table.set_format(*prettytable::format::consts::FORMAT_CLEAN);
|
||||
|
||||
let mut title_row = row!();
|
||||
|
||||
for column in &settings.list_format {
|
||||
title_row.add_cell(Cell::new(&column.label).with_style(Attr::Bold));
|
||||
if stdout().is_terminal() {
|
||||
table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS);
|
||||
} else {
|
||||
table.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
}
|
||||
|
||||
table.set_titles(title_row);
|
||||
// Create header row
|
||||
let mut header_cells = Vec::new();
|
||||
for column in &settings.list_format {
|
||||
header_cells.push(Cell::new(&column.label).add_attribute(Attribute::Bold));
|
||||
}
|
||||
table.set_header(header_cells);
|
||||
|
||||
for item_with_meta in items_with_meta {
|
||||
let tags: Vec<String> = item_with_meta.tags.iter().map(|t| t.name.clone()).collect();
|
||||
|
||||
Reference in New Issue
Block a user