feat: add --generate-config mode to output default config
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
use anyhow::Result;
|
||||
use clap::Command;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_yaml;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct DefaultConfig {
|
||||
dir: Option<String>,
|
||||
list_format: Vec<String>,
|
||||
human_readable: bool,
|
||||
output_format: Option<String>,
|
||||
quiet: bool,
|
||||
server: Option<ServerConfig>,
|
||||
compression_plugins: Vec<String>,
|
||||
meta_plugins: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct ServerConfig {
|
||||
address: Option<String>,
|
||||
port: Option<u16>,
|
||||
password_file: Option<String>,
|
||||
password: Option<String>,
|
||||
password_hash: Option<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(),
|
||||
],
|
||||
human_readable: false,
|
||||
output_format: Some("table".to_string()),
|
||||
quiet: false,
|
||||
server: Some(ServerConfig {
|
||||
address: Some("127.0.0.1".to_string()),
|
||||
port: Some(8080),
|
||||
password_file: None,
|
||||
password: None,
|
||||
password_hash: None,
|
||||
}),
|
||||
compression_plugins: vec![],
|
||||
meta_plugins: vec![],
|
||||
};
|
||||
|
||||
// Serialize to YAML and print to stdout
|
||||
let yaml = serde_yaml::to_string(&default_config)?;
|
||||
println!("{}", yaml);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
pub mod common;
|
||||
pub mod delete;
|
||||
pub mod diff;
|
||||
pub mod generate_config;
|
||||
pub mod get;
|
||||
pub mod info;
|
||||
pub mod list;
|
||||
|
||||
Reference in New Issue
Block a user