aboutsummaryrefslogtreecommitdiff
path: root/src/cli.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-07-10 17:11:50 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-07-10 17:28:31 +0300
commit3e8f9df14e6dd08a8d80d920b923870a80649f0b (patch)
treeea854ca617d1ca21a09d1e7aa9246ffc5f6e842b /src/cli.rs
parent66be0b655fe922867f1eed100a41d67038b6ffd6 (diff)
fix: improve config diagnostic delivery
Diffstat (limited to 'src/cli.rs')
-rw-r--r--src/cli.rs28
1 files changed, 28 insertions, 0 deletions
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<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");
}