feat: add max_len support to ColumnConfig and default list format
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -11,6 +11,8 @@ pub struct ColumnConfig {
|
|||||||
pub label: String,
|
pub label: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub align: ColumnAlignment,
|
pub align: ColumnAlignment,
|
||||||
|
#[serde(default)]
|
||||||
|
pub max_len: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
@@ -32,6 +34,8 @@ impl<'de> serde::Deserialize<'de> for ColumnConfig {
|
|||||||
label: Option<String>,
|
label: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
align: ColumnAlignment,
|
align: ColumnAlignment,
|
||||||
|
#[serde(default)]
|
||||||
|
max_len: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
let helper = Helper::deserialize(deserializer)?;
|
let helper = Helper::deserialize(deserializer)?;
|
||||||
@@ -41,6 +45,7 @@ impl<'de> serde::Deserialize<'de> for ColumnConfig {
|
|||||||
name: helper.name,
|
name: helper.name,
|
||||||
label,
|
label,
|
||||||
align: helper.align,
|
align: helper.align,
|
||||||
|
max_len: helper.max_len,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -198,11 +203,36 @@ impl Settings {
|
|||||||
if settings.list_format.is_empty() {
|
if settings.list_format.is_empty() {
|
||||||
debug!("CONFIG: Setting default list_format");
|
debug!("CONFIG: Setting default list_format");
|
||||||
settings.list_format = vec![
|
settings.list_format = vec![
|
||||||
ColumnConfig { name: "id".to_string(), label: "id".to_string(), align: ColumnAlignment::Left },
|
ColumnConfig {
|
||||||
ColumnConfig { name: "time".to_string(), label: "time".to_string(), align: ColumnAlignment::Left },
|
name: "id".to_string(),
|
||||||
ColumnConfig { name: "size".to_string(), label: "size".to_string(), align: ColumnAlignment::Left },
|
label: "id".to_string(),
|
||||||
ColumnConfig { name: "tags".to_string(), label: "tags".to_string(), align: ColumnAlignment::Left },
|
align: ColumnAlignment::Left,
|
||||||
ColumnConfig { name: "meta:hostname".to_string(), label: "hostname".to_string(), align: ColumnAlignment::Left },
|
max_len: Some(8),
|
||||||
|
},
|
||||||
|
ColumnConfig {
|
||||||
|
name: "time".to_string(),
|
||||||
|
label: "time".to_string(),
|
||||||
|
align: ColumnAlignment::Left,
|
||||||
|
max_len: Some(19),
|
||||||
|
},
|
||||||
|
ColumnConfig {
|
||||||
|
name: "size".to_string(),
|
||||||
|
label: "size".to_string(),
|
||||||
|
align: ColumnAlignment::Left,
|
||||||
|
max_len: Some(10),
|
||||||
|
},
|
||||||
|
ColumnConfig {
|
||||||
|
name: "tags".to_string(),
|
||||||
|
label: "tags".to_string(),
|
||||||
|
align: ColumnAlignment::Left,
|
||||||
|
max_len: Some(20),
|
||||||
|
},
|
||||||
|
ColumnConfig {
|
||||||
|
name: "meta:hostname".to_string(),
|
||||||
|
label: "hostname".to_string(),
|
||||||
|
align: ColumnAlignment::Left,
|
||||||
|
max_len: Some(15),
|
||||||
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ pub fn mode_list(
|
|||||||
.unwrap_or_else(|_| panic!("Unknown column {:?}", column.name));
|
.unwrap_or_else(|_| panic!("Unknown column {:?}", column.name));
|
||||||
|
|
||||||
let mut meta_name: Option<&str> = None;
|
let mut meta_name: Option<&str> = None;
|
||||||
let column_width = 0; // We're not supporting width in the new format
|
let column_width = column.max_len.unwrap_or(0);
|
||||||
|
|
||||||
if let ColumnType::Meta = column_type {
|
if let ColumnType::Meta = column_type {
|
||||||
let parts: Vec<&str> = column.name.split(':').collect();
|
let parts: Vec<&str> = column.name.split(':').collect();
|
||||||
|
|||||||
Reference in New Issue
Block a user