feat: update config system and list format structure
Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -82,23 +82,21 @@ pub fn mode_list(
|
||||
let mut table = Table::new();
|
||||
table.set_format(*prettytable::format::consts::FORMAT_CLEAN);
|
||||
|
||||
let list_format = settings.list_format.split(",");
|
||||
|
||||
let mut title_row = row!();
|
||||
|
||||
for column in list_format.clone() {
|
||||
let mut column_format = column.split(":");
|
||||
let column_name = column_format.next().expect("Unable to parse column name");
|
||||
let column_type = ColumnType::from_str(column_name)
|
||||
.map_err(|_| anyhow!("Unknown column {:?}", column_name))?;
|
||||
for column in &settings.list_format {
|
||||
let column_type = ColumnType::from_str(&column.name)
|
||||
.map_err(|_| anyhow!("Unknown column {:?}", column.name))?;
|
||||
|
||||
if column_type == ColumnType::Meta {
|
||||
let meta_name = column_format
|
||||
.next()
|
||||
.expect("Unable to parse metadata name for meta column");
|
||||
title_row.add_cell(Cell::new(meta_name).with_style(Attr::Bold));
|
||||
let parts: Vec<&str> = column.name.split(':').collect();
|
||||
if parts.len() > 1 {
|
||||
title_row.add_cell(Cell::new(parts[1]).with_style(Attr::Bold));
|
||||
} else {
|
||||
title_row.add_cell(Cell::new(&column.label).with_style(Attr::Bold));
|
||||
}
|
||||
} else {
|
||||
title_row.add_cell(Cell::new(&column_type.to_string()).with_style(Attr::Bold));
|
||||
title_row.add_cell(Cell::new(&column.label).with_style(Attr::Bold));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,22 +111,20 @@ pub fn mode_list(
|
||||
|
||||
let mut table_row = Row::new(vec![]);
|
||||
|
||||
for column in list_format.clone() {
|
||||
let mut column_format = column.split(":");
|
||||
let column_name = column_format.next().expect("Unable to parse column name");
|
||||
let column_type = ColumnType::from_str(column_name)
|
||||
.unwrap_or_else(|_| panic!("Unknown column {:?}", column_name));
|
||||
for column in &settings.list_format {
|
||||
let column_type = ColumnType::from_str(&column.name)
|
||||
.unwrap_or_else(|_| panic!("Unknown column {:?}", column.name));
|
||||
|
||||
let mut meta_name: Option<&str> = None;
|
||||
let column_width = 0; // We're not supporting width in the new format
|
||||
|
||||
if column_type == ColumnType::Meta {
|
||||
meta_name = column_format.next();
|
||||
let parts: Vec<&str> = column.name.split(':').collect();
|
||||
if parts.len() > 1 {
|
||||
meta_name = Some(parts[1]);
|
||||
}
|
||||
}
|
||||
|
||||
let column_width: usize = match column_format.next() {
|
||||
Some(len) => len.parse().unwrap_or(0),
|
||||
None => 0,
|
||||
};
|
||||
|
||||
let cell = match column_type {
|
||||
ColumnType::Id => Cell::new_align(
|
||||
&string_column(item.id.unwrap_or(0).to_string(), column_width),
|
||||
|
||||
Reference in New Issue
Block a user