From 3e8f9df14e6dd08a8d80d920b923870a80649f0b Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Fri, 10 Jul 2026 17:11:50 +0300 Subject: fix: improve config diagnostic delivery --- src/cli.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/cli.rs') diff --git a/src/cli.rs b/src/cli.rs index 58bd3a54..494ed14e 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -224,6 +224,7 @@ fn run_config_command(args: &[String]) -> std::io::Result { }; match subcommand { + "check" => config_check(&args[1..]), "reset-keys" => config_reset_keys(&args[1..]), "help" | "--help" | "-h" => { print_config_help(); @@ -236,6 +237,32 @@ fn run_config_command(args: &[String]) -> std::io::Result { } } +fn config_check(args: &[String]) -> std::io::Result { + match args { + [] => {} + [flag] if matches!(flag.as_str(), "help" | "--help" | "-h") => { + eprintln!("usage: herdr config check"); + return Ok(0); + } + _ => { + eprintln!("usage: herdr config check"); + return Ok(2); + } + } + + let diagnostics = crate::config::Config::load().diagnostics; + if diagnostics.is_empty() { + println!("config: ok"); + } else { + println!("config: issues found"); + for diagnostic in &diagnostics { + println!("{diagnostic}"); + } + } + + Ok(i32::from(!diagnostics.is_empty())) +} + fn config_reset_keys(args: &[String]) -> std::io::Result { if !args.is_empty() { eprintln!("usage: herdr config reset-keys"); @@ -1119,6 +1146,7 @@ fn print_session_error(code: &str, message: &str) { fn print_config_help() { eprintln!("herdr config commands:"); + eprintln!(" herdr config check validate config.toml and print diagnostics"); eprintln!(" herdr config reset-keys back up config.toml and remove custom keybindings"); } -- cgit v1.2.3