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:
@@ -6,13 +6,32 @@ use serde_yaml;
|
|||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
struct DefaultConfig {
|
struct DefaultConfig {
|
||||||
dir: Option<String>,
|
dir: Option<String>,
|
||||||
list_format: Vec<String>,
|
list_format: Vec<ColumnConfig>,
|
||||||
human_readable: bool,
|
human_readable: bool,
|
||||||
output_format: Option<String>,
|
output_format: Option<String>,
|
||||||
quiet: bool,
|
quiet: bool,
|
||||||
|
force: bool,
|
||||||
server: Option<ServerConfig>,
|
server: Option<ServerConfig>,
|
||||||
compression_plugins: Vec<String>,
|
compression_plugin: Option<CompressionPluginConfig>,
|
||||||
meta_plugins: Vec<String>,
|
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)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
@@ -24,20 +43,60 @@ struct ServerConfig {
|
|||||||
password_hash: Option<String>,
|
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<()> {
|
pub fn mode_generate_config(_cmd: &mut Command, _settings: &crate::config::Settings) -> Result<()> {
|
||||||
// Create a default configuration
|
// Create a default configuration
|
||||||
let default_config = DefaultConfig {
|
let default_config = DefaultConfig {
|
||||||
dir: Some("~/.local/share/keep".to_string()),
|
dir: Some("~/.local/share/keep".to_string()),
|
||||||
list_format: vec![
|
list_format: vec![
|
||||||
"id".to_string(),
|
ColumnConfig {
|
||||||
"time".to_string(),
|
name: "id".to_string(),
|
||||||
"size".to_string(),
|
label: Some("id".to_string()),
|
||||||
"tags".to_string(),
|
align: ColumnAlignment::Left,
|
||||||
"meta:hostname".to_string(),
|
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,
|
human_readable: false,
|
||||||
output_format: Some("table".to_string()),
|
output_format: Some("table".to_string()),
|
||||||
quiet: false,
|
quiet: false,
|
||||||
|
force: false,
|
||||||
server: Some(ServerConfig {
|
server: Some(ServerConfig {
|
||||||
address: Some("127.0.0.1".to_string()),
|
address: Some("127.0.0.1".to_string()),
|
||||||
port: Some(8080),
|
port: Some(8080),
|
||||||
@@ -45,8 +104,8 @@ pub fn mode_generate_config(_cmd: &mut Command, _settings: &crate::config::Setti
|
|||||||
password: None,
|
password: None,
|
||||||
password_hash: None,
|
password_hash: None,
|
||||||
}),
|
}),
|
||||||
compression_plugins: vec![],
|
compression_plugin: None,
|
||||||
meta_plugins: vec![],
|
meta_plugins: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Serialize to YAML and print to stdout
|
// Serialize to YAML and print to stdout
|
||||||
|
|||||||
Reference in New Issue
Block a user