diff --git a/src/modes/generate_config.rs b/src/modes/generate_config.rs index 0273a71..e4e8da0 100644 --- a/src/modes/generate_config.rs +++ b/src/modes/generate_config.rs @@ -6,13 +6,32 @@ use serde_yaml; #[derive(Debug, Serialize, Deserialize)] struct DefaultConfig { dir: Option, - list_format: Vec, + list_format: Vec, human_readable: bool, output_format: Option, quiet: bool, + force: bool, server: Option, - compression_plugins: Vec, - meta_plugins: Vec, + compression_plugin: Option, + meta_plugins: Option>, +} + +#[derive(Debug, Serialize, Deserialize)] +struct ColumnConfig { + name: String, + label: Option, + #[serde(default)] + align: ColumnAlignment, + #[serde(default)] + max_len: Option, +} + +#[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, } +#[derive(Debug, Serialize, Deserialize)] +struct CompressionPluginConfig { + name: String, +} + +#[derive(Debug, Serialize, Deserialize)] +struct MetaPluginConfig { + name: String, + #[serde(default)] + options: std::collections::HashMap, + #[serde(default)] + outputs: std::collections::HashMap, +} + 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