mirror of
https://git.alemi.dev/guestbook.rs.git
synced 2024-12-18 18:54:51 +01:00
feat: guestbook config <file> shows merged config
This commit is contained in:
parent
32b20000c1
commit
9e5b2ffb13
1 changed files with 13 additions and 3 deletions
16
src/main.rs
16
src/main.rs
|
@ -44,8 +44,11 @@ enum CliAction {
|
|||
config: Option<String>,
|
||||
},
|
||||
|
||||
/// 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<String>,
|
||||
},
|
||||
|
||||
/// 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
|
||||
|
|
Loading…
Reference in a new issue