From 9e5b2ffb13b8f2cca3553bc5c4d308318709f293 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 3 Jan 2024 19:54:13 +0100 Subject: [PATCH] feat: guestbook config shows merged config --- src/main.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index ce03551..5910b87 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,8 +44,11 @@ enum CliAction { config: Option, }, - /// print a sample configuration, redirect to file and customize - Config, + /// show resulting configuration, if no path is given show full default config + Config { + /// path to config file to process + path: Option, + }, /// review sent pages and approve for public view Review { @@ -64,7 +67,14 @@ async fn main() { .init(); match args.action { - CliAction::Config => println!("{}", toml::to_string(&Config::default()).unwrap()), + CliAction::Config { path } => { + let cfg = if let Some(p) = path { + toml::from_str(&std::fs::read_to_string(p).unwrap()).unwrap() + } else { + Config::default() + }; + println!("{}", toml::to_string(&cfg).unwrap()) + }, CliAction::Review { batch } => { use std::io::Write; sqlx::any::install_default_drivers(); // must install all available drivers before connecting