feat: update config generation to match settings struct format

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-27 22:31:52 -03:00
parent bc78075b1a
commit 5541220a68

View File

@@ -6,13 +6,32 @@ use serde_yaml;
#[derive(Debug, Serialize, Deserialize)]
struct DefaultConfig {
dir: Option<String>,
list_format: Vec<String>,
list_format: Vec<ColumnConfig>,
human_readable: bool,
output_format: Option<String>,
quiet: bool,
force: bool,
server: Option<ServerConfig>,
compression_plugins: Vec<String>,
meta_plugins: Vec<String>,
compression_plugin: Option<CompressionPluginConfig>,
meta_plugins: Option<Vec<MetaPluginConfig>>,
}
#[derive(Debug, Serialize, Deserialize)]
struct ColumnConfig {
name: String,
label: Option<String>,
#[serde(default)]
align: ColumnAlignment,
#[serde(default)]
max_len: Option<String>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
#[serde(rename_all = "lowercase")]
enum ColumnAlignment {
#[default]
Left,
Right,
}
#[derive(Debug, Serialize, Deserialize)]
@@ -24,20 +43,60 @@ struct ServerConfig {
password_hash: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
struct CompressionPluginConfig {
name: String,
}
#[derive(Debug, Serialize, Deserialize)]
struct MetaPluginConfig {
name: String,
#[serde(default)]
options: std::collections::HashMap<String, serde_yaml::Value>,
#[serde(default)]
outputs: std::collections::HashMap<String, String>,
}
pub fn mode_generate_config(_cmd: &mut Command, _settings: &crate::config::Settings) -> Result<()> {
// Create a default configuration
let default_config = DefaultConfig {
dir: Some("~/.local/share/keep".to_string()),
list_format: vec![
"id".to_string(),
"time".to_string(),
"size".to_string(),
"tags".to_string(),
"meta:hostname".to_string(),
ColumnConfig {
name: "id".to_string(),
label: Some("id".to_string()),
align: ColumnAlignment::Left,
max_len: Some("8".to_string()),
},
ColumnConfig {
name: "time".to_string(),
label: Some("time".to_string()),
align: ColumnAlignment::Left,
max_len: Some("19".to_string()),
},
ColumnConfig {
name: "size".to_string(),
label: Some("size".to_string()),
align: ColumnAlignment::Left,
max_len: Some("10".to_string()),
},
ColumnConfig {
name: "tags".to_string(),
label: Some("tags".to_string()),
align: ColumnAlignment::Left,
max_len: Some("20".to_string()),
},
ColumnConfig {
name: "meta:hostname".to_string(),
label: Some("hostname".to_string()),
align: ColumnAlignment::Left,
max_len: Some("15".to_string()),
},
],
human_readable: false,
output_format: Some("table".to_string()),
quiet: false,
force: false,
server: Some(ServerConfig {
address: Some("127.0.0.1".to_string()),
port: Some(8080),
@@ -45,8 +104,8 @@ pub fn mode_generate_config(_cmd: &mut Command, _settings: &crate::config::Setti
password: None,
password_hash: None,
}),
compression_plugins: vec![],
meta_plugins: vec![],
compression_plugin: None,
meta_plugins: None,
};
// Serialize to YAML and print to stdout