add default flag for print-config
This commit is contained in:
parent
f0930ab2eb
commit
669441bf4c
17
src/main.rs
17
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() {
|
||||
|
|
Loading…
Reference in New Issue