From 669441bf4ccd9dc6d2979a39467dc9a25789e34f Mon Sep 17 00:00:00 2001 From: emilis Date: Sun, 3 Mar 2024 09:46:46 +0000 Subject: [PATCH] add default flag for print-config --- src/main.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 680fcb1..fc5fbb1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,7 +34,11 @@ enum HlctlCommand { The configuration file located at $HOME/.config/herbstluftwm/hlctl.toml"#)] Save, /// Print the toml config to stdout - PrintConfig, + PrintConfig { + /// Print default config instead of config that `save` would use + #[arg(short, long)] + default: bool, + }, /// Start the top panel Panel, } @@ -46,7 +50,7 @@ fn main() { match args.command { HlctlCommand::Init => init(), HlctlCommand::Save => save(), - HlctlCommand::PrintConfig => print_config(), + HlctlCommand::PrintConfig { default } => print_config(default), HlctlCommand::Panel => { if let Err(err) = panel::panel(&merged_config()) { error!("panel: {err}"); @@ -105,8 +109,13 @@ fn merged_config() -> Config { collected } -fn print_config() { - println!("{}", merged_config().serialize().unwrap()) +fn print_config(default: bool) { + let cfg = if default { + Config::default() + } else { + merged_config() + }; + println!("{}", cfg.serialize().unwrap()) } fn save() {