add default flag for print-config

This commit is contained in:
emilis 2024-03-03 09:46:46 +00:00
parent f0930ab2eb
commit 669441bf4c
1 changed files with 13 additions and 4 deletions

View File

@ -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() {