diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-10 17:11:50 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-10 17:28:31 +0300 |
| commit | 3e8f9df14e6dd08a8d80d920b923870a80649f0b (patch) | |
| tree | ea854ca617d1ca21a09d1e7aa9246ffc5f6e842b /src/cli.rs | |
| parent | 66be0b655fe922867f1eed100a41d67038b6ffd6 (diff) | |
fix: improve config diagnostic delivery
Diffstat (limited to 'src/cli.rs')
| -rw-r--r-- | src/cli.rs | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -224,6 +224,7 @@ fn run_config_command(args: &[String]) -> std::io::Result<i32> { }; 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<i32> { } } +fn config_check(args: &[String]) -> std::io::Result<i32> { + 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<i32> { 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"); } |
