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"#)]
 | 
							The configuration file located at $HOME/.config/herbstluftwm/hlctl.toml"#)]
 | 
				
			||||||
    Save,
 | 
					    Save,
 | 
				
			||||||
    /// Print the toml config to stdout
 | 
					    /// 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
 | 
					    /// Start the top panel
 | 
				
			||||||
    Panel,
 | 
					    Panel,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -46,7 +50,7 @@ fn main() {
 | 
				
			||||||
    match args.command {
 | 
					    match args.command {
 | 
				
			||||||
        HlctlCommand::Init => init(),
 | 
					        HlctlCommand::Init => init(),
 | 
				
			||||||
        HlctlCommand::Save => save(),
 | 
					        HlctlCommand::Save => save(),
 | 
				
			||||||
        HlctlCommand::PrintConfig => print_config(),
 | 
					        HlctlCommand::PrintConfig { default } => print_config(default),
 | 
				
			||||||
        HlctlCommand::Panel => {
 | 
					        HlctlCommand::Panel => {
 | 
				
			||||||
            if let Err(err) = panel::panel(&merged_config()) {
 | 
					            if let Err(err) = panel::panel(&merged_config()) {
 | 
				
			||||||
                error!("panel: {err}");
 | 
					                error!("panel: {err}");
 | 
				
			||||||
| 
						 | 
					@ -105,8 +109,13 @@ fn merged_config() -> Config {
 | 
				
			||||||
    collected
 | 
					    collected
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn print_config() {
 | 
					fn print_config(default: bool) {
 | 
				
			||||||
    println!("{}", merged_config().serialize().unwrap())
 | 
					    let cfg = if default {
 | 
				
			||||||
 | 
					        Config::default()
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        merged_config()
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    println!("{}", cfg.serialize().unwrap())
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn save() {
 | 
					fn save() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue