fix: Resolve multiple ColumnConfig definitions and type mismatches

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 19:04:30 -03:00
parent 0ab5c93845
commit b9059da814
3 changed files with 18 additions and 20 deletions

View File

@@ -5,16 +5,6 @@ use serde::{Deserialize, Serialize};
use log::{debug, error}; use log::{debug, error};
use crate::args::{Args}; use crate::args::{Args};
#[derive(Debug, Clone, Serialize)]
pub struct ColumnConfig {
pub name: String,
pub label: String,
#[serde(default)]
pub align: ColumnAlignment,
#[serde(default)]
pub max_len: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)] #[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "lowercase")] #[serde(rename_all = "lowercase")]
pub enum ColumnAlignment { pub enum ColumnAlignment {
@@ -122,6 +112,14 @@ impl<'de> serde::Deserialize<'de> for ColumnConfig {
align: ColumnAlignment, align: ColumnAlignment,
#[serde(default)] #[serde(default)]
max_len: Option<String>, max_len: Option<String>,
#[serde(default)]
fg_color: Option<TableColor>,
#[serde(default)]
bg_color: Option<TableColor>,
#[serde(default)]
attributes: Vec<TableAttribute>,
#[serde(default)]
padding: Option<(u16, u16)>,
} }
let helper = Helper::deserialize(deserializer)?; let helper = Helper::deserialize(deserializer)?;
@@ -132,6 +130,10 @@ impl<'de> serde::Deserialize<'de> for ColumnConfig {
label, label,
align: helper.align, align: helper.align,
max_len: helper.max_len, max_len: helper.max_len,
fg_color: helper.fg_color,
bg_color: helper.bg_color,
attributes: helper.attributes,
padding: helper.padding,
}) })
} }
} }

View File

@@ -177,10 +177,10 @@ pub fn create_table_with_config(table_config: &crate::config::TableConfig) -> Ta
// Set content arrangement // Set content arrangement
match table_config.content_arrangement { match table_config.content_arrangement {
ContentArrangement::Dynamic => table.set_content_arrangement(ContentArrangement::Dynamic), crate::config::ContentArrangement::Dynamic => table.set_content_arrangement(comfy_table::ContentArrangement::Dynamic),
ContentArrangement::DynamicFullWidth => table.set_content_arrangement(ContentArrangement::DynamicFullWidth), crate::config::ContentArrangement::DynamicFullWidth => table.set_content_arrangement(comfy_table::ContentArrangement::DynamicFullWidth),
ContentArrangement::Disabled => table.set_content_arrangement(ContentArrangement::Disabled), crate::config::ContentArrangement::Disabled => table.set_content_arrangement(comfy_table::ContentArrangement::Disabled),
} };
// Set style preset // Set style preset
match &table_config.style { match &table_config.style {
@@ -199,6 +199,7 @@ pub fn create_table_with_config(table_config: &crate::config::TableConfig) -> Ta
table.load_preset(comfy_table::presets::NOTHING); table.load_preset(comfy_table::presets::NOTHING);
} }
// Add more presets as needed // Add more presets as needed
table
} }
} }
@@ -207,8 +208,6 @@ pub fn create_table_with_config(table_config: &crate::config::TableConfig) -> Ta
match modifier.as_str() { match modifier.as_str() {
"UTF8_SOLID_INNER_BORDERS" => table.apply_modifier(comfy_table::modifiers::UTF8_SOLID_INNER_BORDERS), "UTF8_SOLID_INNER_BORDERS" => table.apply_modifier(comfy_table::modifiers::UTF8_SOLID_INNER_BORDERS),
"UTF8_ROUND_CORNERS" => table.apply_modifier(comfy_table::modifiers::UTF8_ROUND_CORNERS), "UTF8_ROUND_CORNERS" => table.apply_modifier(comfy_table::modifiers::UTF8_ROUND_CORNERS),
"UTF8_NO_BORDERS" => table.apply_modifier(comfy_table::modifiers::UTF8_NO_BORDERS),
"UTF8_NO_LINES" => table.apply_modifier(comfy_table::modifiers::UTF8_NO_LINES),
_ => {} // Ignore unknown modifiers _ => {} // Ignore unknown modifiers
} }
} }

View File

@@ -4,14 +4,11 @@ use crate::services::types::ItemWithMeta;
use crate::modes::common::ColumnType; use crate::modes::common::ColumnType;
use crate::modes::common::{format_size, OutputFormat}; use crate::modes::common::{format_size, OutputFormat};
use anyhow::{Result}; use anyhow::{Result};
use comfy_table::{Table, ContentArrangement, Cell, Row, Color, Attribute}; use comfy_table::{Cell, Row, Color, Attribute};
use comfy_table::presets::NOTHING;
use comfy_table::CellAlignment; use comfy_table::CellAlignment;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json; use serde_json;
use serde_yaml; use serde_yaml;
use std::io::{stdout};
use std::io::IsTerminal;
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
struct ListItem { struct ListItem {